Code example for AtomicLong

Methods: getAndIncrement

0
 */ 
public class TransactionId implements Serializable {
 
  private static final long serialVersionUID = 1L;
 
  private final static AtomicLong counter = new AtomicLong(0);
  private final long myid;
   
  public final static TransactionId NULL_TRANSACTION_ID = new TransactionId();
 
  public TransactionId() { 
    myid = counter.getAndIncrement();
  } 
 
  public long getId() { 
    return myid;
  } 
 
  @Override 
  public int hashCode() { 
    final int prime = 31;