| @@ -46,15 +46,19 @@ public class IdWorker { | |||||
| ///////////////////////////////////////////////////////////////////////////////// | ///////////////////////////////////////////////////////////////////////////////// | ||||
| private static class IdGenHolder { | |||||
| private static final IdWorker instance = new IdWorker(); | |||||
| } | |||||
| public static IdWorker get(){ | |||||
| return IdGenHolder.instance; | |||||
| private static IdWorker instance = null; | |||||
| public static IdWorker get() { | |||||
| if(instance == null) { | |||||
| synchronized (IdWorker.class){ | |||||
| if(instance==null){ | |||||
| instance = new IdWorker(); | |||||
| } | |||||
| } | |||||
| } | |||||
| return instance; | |||||
| } | } | ||||
| public IdWorker() { | |||||
| private IdWorker() { | |||||
| this(0L, 0L); | this(0L, 0L); | ||||
| } | } | ||||