1 46 package org.mr.kernel; 47 48 import java.util.Random ; 49 50 import org.mr.core.util.SystemTime; 51 52 53 61 public class UniqueIDGenerator { 62 63 private static long id = 0; 64 static boolean init = false; 65 66 71 public synchronized static long getNextMessageID() { 72 if(!init){ 73 id =(random.nextInt() << 32 + (int)(SystemTime.currentTimeMillis() & 0xFFFFFFFF)); 74 init = true; 75 } 76 77 id++; 78 return id; 79 } 81 82 private static final Random random = new Random (); 83 } | Popular Tags |