From 5e24340526544d1e33879025c19f4afd70bad39d Mon Sep 17 00:00:00 2001 From: yitter Date: Mon, 6 Jun 2022 22:48:35 +0800 Subject: [PATCH] auto commit --- C#.NET/source/Yitter.IdGenTest/Program.cs | 2 +- C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/C#.NET/source/Yitter.IdGenTest/Program.cs b/C#.NET/source/Yitter.IdGenTest/Program.cs index 6805258..099615f 100644 --- a/C#.NET/source/Yitter.IdGenTest/Program.cs +++ b/C#.NET/source/Yitter.IdGenTest/Program.cs @@ -11,7 +11,7 @@ namespace Yitter.OrgSystem.TestA class Program { // 测试参数(默认配置下,最佳性能是10W/s) - static int genIdCount = 2;//50000; // 计算ID数量(如果要验证50W效率,请将TopOverCostCount设置为20000或适当增加SeqBitLength) + static int genIdCount = 2;//5000; // 计算ID数量(如果要验证50W效率,请将TopOverCostCount设置为20000或适当增加SeqBitLength) static short method = 1; // 1-漂移算法,2-传统算法 diff --git a/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs b/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs index 1127609..f53f6c7 100644 --- a/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs +++ b/C#.NET/source/Yitter.IdGenerator/YitIdHelper.cs @@ -41,9 +41,15 @@ namespace Yitter.IdGenerator { if (_IdGenInstance == null) { - _IdGenInstance = new DefaultIdGenerator( - new IdGeneratorOptions() { WorkerId = 0 } - ); + lock (_IdGenInstance) + { + if (_IdGenInstance == null) + { + _IdGenInstance = new DefaultIdGenerator( + new IdGeneratorOptions() { WorkerId = 0 } + ); + } + } } return _IdGenInstance.NewLong();