Java AtomicLong generateId()

Here you can find the source of generateId()

Description

generate Id

License

Apache License

Declaration

public static String generateId() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.concurrent.atomic.AtomicLong;

public class Main {
    private static AtomicLong counter = new AtomicLong(1);

    public static String generateId() {
        return counter.getAndIncrement() + "-" + System.currentTimeMillis();
    }//  w  w w.j  a  v a2 s  .  c o  m
}

Related

  1. createAtomicId()
  2. createId(final Long baseId)
  3. createObjectID()
  4. createUniqueFileName(String out)
  5. currentDate()
  6. generateId()
  7. generateRandom()
  8. get(T stat, AtomicIntegerFieldUpdater updater, boolean reset)
  9. getAndAddCap(AtomicLongFieldUpdater updater, T instance, long n)