From 8a0a7a8b86e94e5d7923cd7eb52808a2bebdd557 Mon Sep 17 00:00:00 2001 From: shijie <648688341@qq.com> Date: Wed, 9 Sep 2020 12:04:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=AA=E8=8A=B1=E7=AE=97=E6=B3=95=E7=94=9F?= =?UTF-8?q?=E6=88=90id=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/utils/SnowflakeIdUtils.java | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) 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