@@ -11,7 +11,7 @@ namespace Yitter.OrgSystem.TestA | |||||
class Program | class Program | ||||
{ | { | ||||
// 测试参数(默认配置下,最佳性能是10W/s) | // 测试参数(默认配置下,最佳性能是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-传统算法 | static short method = 1; // 1-漂移算法,2-传统算法 | ||||
@@ -41,9 +41,15 @@ namespace Yitter.IdGenerator | |||||
{ | { | ||||
if (_IdGenInstance == null) | 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(); | return _IdGenInstance.NewLong(); | ||||