As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
final TimeBasedGenerator timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface()); final Set<UUID> ids = new HashSet<UUID>(); Runnable r = new Runnable() { public void run() { for (int i = 0; i < 10000; i++) { UUID id = timeBasedGenerator.generate(); synchronized (ids) { if (!ids.add(id)) { throw new RuntimeException("Id not unique: " + id); } } } } }; ExecutorService executorService = Executors.newFixedThreadPool(5); for (int i = 0; i < 2; i++) { executorService.execute(r); } executorService.shutdown();