public void waitForEvent(long timeout){
  Thread thread=Thread.currentThread();
  Semaphore semaphore=_semaphores.get(thread);
  if (semaphore == null) {
    semaphore=new Semaphore(1,true);
    semaphore.drainPermits();
    _semaphores.putIfAbsent(thread,semaphore);
  }
  semaphore=_semaphores.get(thread);
  try {
    semaphore.tryAcquire(timeout,TimeUnit.MILLISECONDS);
  }
 catch (  InterruptedException exception) {
    logger.log(Level.FINER,"Exception ",exception);
  }
}

public void waitForEvent ( long timeout ) { Thread thread = Thread . currentThread ( ) ; Semaphore semaphore = _semaphores . get ( thread ) ; if ( semaphore == null ) { semaphore = new Semaphore ( 1 , true ) ; semaphore . drainPermits ( ) ; _semaphores . putIfAbsent ( thread , semaphore ) ; } semaphore = _semaphores . get ( thread ) ; try { semaphore . tryAcquire ( timeout , TimeUnit . MILLISECONDS ) ; } catch ( InterruptedException exception ) { logger . log ( Level . FINER , "Exception " , exception ) ; } }
blocks the current thread until the event arrives or the timeout expires .
