diff --git a/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java b/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java index ff508518..8b0fe802 100644 --- a/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java +++ b/dq-framework-utils/src/main/java/com/daqing/framework/utils/SnowflakeIdUtils.java @@ -4,9 +4,10 @@ import java.util.HashSet; import java.util.Set; /** - * @Author:JCccc - * @Description: + * @Author: JCccc + * @Description: 雪花算法生成id工具类 * @Date: created in 15:31 2019/6/12 + * @Modified By: gongsj. 修改为单例模式 modified in 11:50 2020/09/09 */ public class SnowflakeIdUtils { // ==============================Fields=========================================== @@ -174,27 +175,27 @@ public class SnowflakeIdUtils { return SnowflakeIdUtils.getInstance().nextId(); } - public static void main(String[] args) { - - SnowflakeIdUtils snowflakeIdUtils = SnowflakeIdUtils.getInstance(); - -// for (int i = 0; i < 20; i++) { -// System.out.println(snowflakeIdUtils.nextId()); -// } -// System.out.println("-+-+-+-+-+-+-+-+-+-+-+-+-+-"); -// for (int i = 0; i < 20; i++) { -// System.out.println(SnowflakeIdUtils.getInstance().nextId()); -// } -// Set set2 = new HashSet<>(); +// public static void main(String[] args) { +// +// SnowflakeIdUtils snowflakeIdUtils = SnowflakeIdUtils.getInstance(); +// +//// for (int i = 0; i < 20; i++) { +//// System.out.println(snowflakeIdUtils.nextId()); +//// } +//// System.out.println("-+-+-+-+-+-+-+-+-+-+-+-+-+-"); +//// for (int i = 0; i < 20; i++) { +//// System.out.println(SnowflakeIdUtils.getInstance().nextId()); +//// } +//// Set set2 = new HashSet<>(); +//// for (int i = 0; i < 1000000; i++) { +//// set2.add(snowflakeIdUtils.nextId()); +//// } +//// System.out.println(set2.size()); +//// +// Set set = new HashSet<>(); // for (int i = 0; i < 1000000; i++) { -// set2.add(snowflakeIdUtils.nextId()); +// set.add(SnowflakeIdUtils.getRandomid()); // } -// System.out.println(set2.size()); -// - Set set = new HashSet<>(); - for (int i = 0; i < 1000000; i++) { - set.add(SnowflakeIdUtils.getRandomid()); - } - System.out.println(set.size()); - } +// System.out.println(set.size()); +// } } \ No newline at end of file