public static byte[] randomId(){
  byte bits[];
synchronized (idLock) {
    bits=nextId.toByteArray();
    nextId=nextId.add(BigInteger.ONE).and(mask128);
  }
  if (bits.length > ID_LENGTH) {
    assert bits.length == ID_LENGTH + 1;
    assert bits[0] == 0;
    return Arrays.copyOfRange(bits,1,bits.length);
  }
 else {
    byte[] result=new byte[ID_LENGTH];
    System.arraycopy(bits,0,result,result.length - bits.length,bits.length);
    return result;
  }
}

public static byte [ ] randomId ( ) { byte bits [ ] ; synchronized ( idLock ) { bits = nextId . toByteArray ( ) ; nextId = nextId . add ( BigInteger . ONE ) . and ( mask128 ) ; } if ( bits . length > ID_LENGTH ) { assert bits . length == ID_LENGTH + 1 ; assert bits [ 0 ] == 0 ; return Arrays . copyOfRange ( bits , 1 , bits . length ) ; } else { byte [ ] result = new byte [ ID_LENGTH ] ; System . arraycopy ( bits , 0 , result , result . length - bits . length , bits . length ) ; return result ; } }
generates a non - cryptographic globally unique id .
