IdGenerator { public synchronized long snowflakeId() { return snowflake.nextId(); }  synchronized String batchId(int tenantId, int module); @Deprecated synchronized String getBatchId(int tenantId, int module); String simpleUUID(); String randomUUID(); synchronized long snowflakeId(); synchronized long snowflakeId(long workerId, long dataCenterId); String objectId();  }
@Test public void testSnowflakeId() { ExecutorService executorService = Executors.newFixedThreadPool(20); for (int i = 0; i < 20; i++) { executorService.execute(() -> { System.out.println("分布式 ID: " + idGenerator.snowflakeId()); }); } executorService.shutdown(); }