Created
July 30, 2019 01:27
Revisions
-
ggdio created this gist
Jul 30, 2019 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ public class ConcurrentUUIDGenerator { public static UUID randomUUID() { final Random rnd = ThreadLocalRandom.current(); long mostSig = rnd.nextLong(); long leastSig = rnd.nextLong(); // Identify this as a version 4 UUID, that is one based on a random value. mostSig &= 0xffffffffffff0fffL; mostSig |= 0x0000000000004000L; // Set the variant identifier as specified for version 4 UUID values. The two // high order bits of the lower word are required to be one and zero, respectively. leastSig &= 0x3fffffffffffffffL; leastSig |= 0x8000000000000000L; return new UUID(mostSig, leastSig); } }