common/src/main/java/com/genexus/util/Semaphore.java
/** Wait at most msecs millisconds for a permit. **/
Wait at most msecs millisconds for a permit.
Wait at most msecs millisconds for a permit .
public boolean attempt(long msecs) throws InterruptedException {
    if (Thread.interrupted()) throw new InterruptedException();
    synchronized(this) {
      if (permits_ > 0) { 
        --permits_;
        return true;
      }
      else if (msecs <= 0)   
        return false;
      else {
        try {
          long startTime = System.currentTimeMillis();
          long waitTime = msecs;
          for (;;) {
            wait(waitTime);
            if (permits_ > 0) {
              --permits_;
              return true;
            }
            else { 
              waitTime = msecs - (System.currentTimeMillis() - startTime);
              if (waitTime <= 0) 
                return false;
            }
          }
        }
        catch(InterruptedException ex) { 
          notify();
          throw ex;
        }
      }
    }
  }
public boolean attempt ( long msecs ) throws InterruptedException { if ( Thread . interrupted ( ) ) throw new InterruptedException ( ) ; synchronized ( this ) { if ( permits_ > 0 ) { -- permits_ ; return true ; } else if ( msecs <= 0 ) return false ; else { try { long startTime = System . currentTimeMillis ( ) ; long waitTime = msecs ; for ( ; ; ) { wait ( waitTime ) ; if ( permits_ > 0 ) { -- permits_ ; return true ; } else { waitTime = msecs - ( System . currentTimeMillis ( ) - startTime ) ; if ( waitTime <= 0 ) return false ; } } } catch ( InterruptedException ex ) { notify ( ) ; throw ex ; } } } }
Wait at most msecs millisconds for a permit.
Wait at most msecs millisconds for a permit .