Ejemplo n.º 1
0
 private static final synchronized void initSingletonInstance() {
   if (null == singletonInstance) {
     // singletonInstance = SingletonInstance.createFileLock(SINGLE_INSTANCE_LOCK_POLL,
     // SINGLE_INSTANCE_LOCK_FILE);
     singletonInstance =
         SingletonInstance.createServerSocket(
             SINGLE_INSTANCE_LOCK_POLL, SINGLE_INSTANCE_LOCK_PORT);
     if (!singletonInstance.tryLock(SINGLE_INSTANCE_LOCK_TO)) {
       throw new RuntimeException(
           "Fatal: Could not lock single instance: " + singletonInstance.getName());
     }
   }
 }
Ejemplo n.º 2
0
 @AfterClass
 public static void oneTimeTearDown() {
   // one-time cleanup code
   System.gc(); // force cleanup
   singletonInstance.unlock();
 }