@Override
    public boolean tryLock(long time, TimeUnit unit) throws InterruptedException {
      if (readerSemaphore.tryAcquire(time, unit)) {
        int oldNumReaders = numReaders;
        numReaders++;
        if (numReaders == 1) {
          if (writerSemaphore.tryAcquire(time, unit)) {
            readerSemaphore.release();
            return true;
          } else {
            numReaders = oldNumReaders;
            readerSemaphore.release();
            return false;
          }
        } else {
          readerSemaphore.release();
          return true;
        }
      }
      return false;
    }
This ReadWriteLock is useful when different threads need to lock and unlock the read lock. This
is <b>NOT</b> a reentrant lock.
geode-core/src/main/java/org/apache/geode/internal/util/concurrent/SemaphoreReadWriteLock.java