提交 33e6b0a9 编写于 作者: yitter's avatar yitter

NextId中不再创建Generator对象

上级 427bf9d1
...@@ -39,18 +39,18 @@ namespace Yitter.IdGenerator ...@@ -39,18 +39,18 @@ namespace Yitter.IdGenerator
/// <returns></returns> /// <returns></returns>
public static long NextId() public static long NextId()
{ {
if (_IdGenInstance == null) //if (_IdGenInstance == null)
{ //{
lock (_IdGenInstance) // lock (_IdGenInstance)
{ // {
if (_IdGenInstance == null) // if (_IdGenInstance == null)
{ // {
_IdGenInstance = new DefaultIdGenerator( // _IdGenInstance = new DefaultIdGenerator(
new IdGeneratorOptions() { WorkerId = 0 } // new IdGeneratorOptions() { WorkerId = 0 }
); // );
} // }
} // }
} //}
return _IdGenInstance.NewLong(); return _IdGenInstance.NewLong();
} }
......
...@@ -34,9 +34,9 @@ public class YitIdHelper { ...@@ -34,9 +34,9 @@ public class YitIdHelper {
* @return * @return
*/ */
public static long nextId() throws IdGeneratorException { public static long nextId() throws IdGeneratorException {
if (idGenInstance == null) { //if (idGenInstance == null) {
idGenInstance = new DefaultIdGenerator(new IdGeneratorOptions((short) 1)); // idGenInstance = new DefaultIdGenerator(new IdGeneratorOptions((short) 1));
} //}
return idGenInstance.newLong(); return idGenInstance.newLong();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册