Ejemplo n.º 1
0
  public boolean awaitShutdown(long timeout) throws InterruptedException {
    boolean res = false;

    {
      if (resource != null) {
        res = resource.awaitShutdown(timeout);
      }
    }

    return res;
  }
  public synchronized boolean awaitShutdown(long timeout) throws InterruptedException {
    boolean res = false;

    {
      long t0 = System.currentTimeMillis();
      long t1 = t0 + timeout;

      long timeoutLeft = timeout;

      // Await shutdown of the executing synchronizer:
      {
        if (executingSynchronizer != null) {
          executingSynchronizer.awaitShutdown(timeoutLeft);
        }
      }

      // Await shutdown of the locking synchronizers:
      {
        if (lockingSynchronizers != null) {
          synchronized (lockingSynchronizers) {
            Collection<LockingSynchronizer> v = lockingSynchronizers.values();
            if (v != null) {
              for (LockingSynchronizer synchronizer : v) {
                long t = System.currentTimeMillis();
                timeoutLeft = t1 - t;
                if (timeoutLeft <= 0) {
                  break;
                } else {
                  synchronizer.awaitShutdown(timeoutLeft);
                }
              }
            }
          }
        }
      }
    }

    return res;
  }
Ejemplo n.º 3
0
 public void awaitShutdown() throws InterruptedException {
   if (resource != null) {
     resource.awaitShutdown();
   }
 }