This method is only called from code synched on the <code>freeLockObject</code>,
so we do not have to worry about synchronizing access to
<code>waiterCount</code>.
12358
private void queueRequest(ManagedConnectionFactory managedConnectionFactory, long waitTimeout) throws ResourceAllocationException, ConnectionWaitTimeoutException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.entry(this, tc, "queueRequest", waitTimeout);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
            Tr.debug(tc, "Current connection pool", pm.toString());
        if (waitTimeout == 0) {
            --pm.waiterCount;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(
                         tc,
                         "Timeout.  Decremented waiterCount, which is now "
                             + pm.waiterCount
                             + " on datasource "
                             + gConfigProps.cfName);
            }
            Object[] connWaitTimeoutparms = new Object[] { "queueRequest", gConfigProps.cfName, 0, pm.waiterCount,
                                                           pm.totalConnectionCount.get() };
            Tr.error(
                     tc,
                     "POOL_MANAGER_EXCP_CCF2_0001_J2CA0045",
                     connWaitTimeoutparms);
            String connWaitTimeoutMessage = Tr.formatMessage(tc, "POOL_MANAGER_EXCP_CCF2_0001_J2CA0045", connWaitTimeoutparms);
            ConnectionWaitTimeoutException cwte = new ConnectionWaitTimeoutException(connWaitTimeoutMessage);
            com.ibm.ws.ffdc.FFDCFilter.processException(cwte, J2CConstants.DMSID_MAX_CONNECTIONS_REACHED, "192", this.pm);
            pm.activeRequest.decrementAndGet();

            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "queueRequest", cwte);
            throw cwte;
        }
        if ((tc.isDebugEnabled())) {
            ++freePoolQueuedRequests;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                String poolStats = pm.gatherPoolStatisticalData();
                Tr.debug(this, tc, "Queueing Waiter for pool <" + gConfigProps.getXpathId() + ">. Current Pool Stats are:");
                Tr.debug(this, tc, poolStats);
            }
        }
        try {
            if (pm.displayInfiniteWaitMessage) {
                Tr.info(tc, "INFINITE_CONNECTION_WAIT_TIMEOUT_J2CA0127", gConfigProps.getXpathId());

                pm.displayInfiniteWaitMessage = false; // only display this message once per PM.
            }
            pm.activeRequest.decrementAndGet();
            if (waitTimeout < 0) {
                pm.waiterFreePoolLock.wait(0); //wait an infinite amount of time
            } else {
                pm.waiterFreePoolLock.wait(waitTimeout); //wait the specified amount of time
            }
            pm.requestingAccessToPool();
        } catch (InterruptedException ie) {
            if (tc.isDebugEnabled()) {
                Tr.debug(this, tc, "Interupted waiting for a connection");
            }

            synchronized (pm.waiterFreePoolLock) {
                --pm.waiterCount;
            }

            if (tc.isDebugEnabled()) {
                if (pm.waiterCount == 0) {
                    pm.waitersEndedTime = System.currentTimeMillis();
                    Tr.debug(this, tc, "Waiters: requests for connections are no longer being queued. End Time:" + pm.waitersEndedTime);
                    Tr.debug(this, tc, "Waiters: total time waiter were in queue: " + (pm.waitersEndedTime - pm.waitersStartedTime));
                }
            }
            ResourceAllocationException throwMe = new ResourceAllocationException(ie.getMessage());
            throwMe.initCause(ie);
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                Tr.exit(this, tc, "queueRequest", throwMe);
            throw throwMe;
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) {
            Tr.exit(this, tc, "queueRequest");
        }
    }
870152
void writeLock(int count) {
      if (count > 0 && counter != null)
         counter.acquireShared(count);
      sync.acquireShared(1);
   }
252244
public synchronized void unlockExclusive()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "unlockExclusive", this);

    // Synchronize on the locking Mutex.
    synchronized (iMutex)
    {
      // Only release the lock if the holder is the current thread.
      if (Thread.currentThread() == iExclusiveLockHolder)
      {
        if (tc.isDebugEnabled())
          SibTr.debug(tc, "Unlocking current thread " + (iExclusiveLockCount - 1));

        // Decrement the exclusive lock count,
        // if the count reaches 0 then we know that 
        // we can safely remove the exclusive lock
        if (--iExclusiveLockCount == 0)
        {
          // Set the flag to indicate that the exclusive lock
          // has been released.
          iExclusivelyLocked = false;

          // Set the exclusive lock holder thread to be null
          iExclusiveLockHolder = null;

          // Notify any threads waiting for this lock.
          notifyAll();
        }
      }
      else if (tc.isDebugEnabled())
        SibTr.debug(tc, "Thread not the current thread to unlock exclusively");
    }

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "unlockExclusive");

  }
464763
function () {
            var fc = this.freeCount, def, defQueue = this.__deferredQueue;
            while (fc-- >= 0 && defQueue.count) {
                def = defQueue.dequeue();
                var conn = this.getObject();
                if (conn) {
                    def.callback(conn);
                } else {
                    throw new Error("UNEXPECTED ERROR");
                }
                fc--;
            }
        }
1061252
private void syncToOSThread(WebSecurityContext webSecurityContext) throws SecurityViolationException {
        try {
            Object token = ThreadIdentityManager.setAppThreadIdentity(subjectManager.getInvocationSubject());
            webSecurityContext.setSyncToOSThreadToken(token);
        } catch (ThreadIdentityException tie) {
            SecurityViolationException secVE = convertWebSecurityException(new WebSecurityCollaboratorException(tie.getMessage(), DENY_AUTHZ_FAILED, webSecurityContext));
            throw secVE;
        }
    }
585080
@Override
    public LockResult lock(int waitWeight, String clientId) {
        return lock(waitWeight, clientId, DEFAULT_LOCK_DURATION_MS);
    }
1090870
public void freeUseCount()
  {
    if (_indirectSource != null) {
      _indirectSource.freeUseCount();
    }
    else if (_useCount != null) {
      if (_useCount.decrementAndGet() < 0) {
        closeSelf();
      }
    }
  }
375405
void unlockProcessWait(ServerRequest.PROCESS_WAIT_LOCK lock) {
        synchronized (reqQueueLockObject) {
            for (ServerRequest req : queue) {
                if (req != null) {
                    req.removeProcessWaitLock(lock);
                }
            }
        }
    }
876804
private void incrementThreadLockCount()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "incrementThreadLockCount", this);
    //get the current thread
    Thread currentThread = Thread.currentThread();
    //get it's current read lock count
    LockCount count = (LockCount) readerThreads.get(currentThread);
    //if it doesn't exist, create it
    if(count == null)
    {
      count = new LockCount();
      readerThreads.put(currentThread, count);
    }
    //increment the count
    if(count.count == 0) readerThreadCount++;
    count.count++;
    readLockCount++;
    
    if (tc.isEntryEnabled())
      SibTr.exit(tc, "incrementThreadLockCount");
  }
716005
private final synchronized void unlock()
                    throws ObjectManagerException
    {
        final String methodName = "unlock";
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this,
                        cclass,
                        methodName,
                        new Object[] { transactionLock });

        setState(nextStateForUnlock); // Make the state change. 

        transactionLock = new TransactionLock(null);
        numberOfLocksTaken = 0;
        notify(); // Wake up one waiter.

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this,
                       cclass,
                       methodName);
    }
347663
void free(boolean finalizer) {
        // As free() may be called either by the finalizer or by FastThreadLocal.onRemoval(...) we need to ensure
        // we only call this one time.
        if (freed.compareAndSet(false, true)) {
            int numFreed = free(tinySubPageDirectCaches, finalizer) +
                    free(smallSubPageDirectCaches, finalizer) +
                    free(normalDirectCaches, finalizer) +
                    free(tinySubPageHeapCaches, finalizer) +
                    free(smallSubPageHeapCaches, finalizer) +
                    free(normalHeapCaches, finalizer);

            if (numFreed > 0 && logger.isDebugEnabled()) {
                logger.debug("Freed {} thread-local buffer(s) from thread: {}", numFreed,
                        Thread.currentThread().getName());
            }

            if (directArena != null) {
                directArena.numThreadCaches.getAndDecrement();
            }

            if (heapArena != null) {
                heapArena.numThreadCaches.getAndDecrement();
            }
        }
    }
1313782
private void unlockCompletely(ReentrantLock lockToUnlock){
        int counter = lockToUnlock.getHoldCount();

        for(int i = 0; i<counter; i++){
            lockToUnlock.unlock();
        }
    }
1044053
public SynchronizationPoint<IOException> onDone() {
		synchronized (buffers) {
			if (writing == null) return new SynchronizationPoint<>(true);
			if (writing.hasError()) return new SynchronizationPoint<IOException>(writing.getError());
			if (writing.isCancelled()) return new SynchronizationPoint<IOException>(writing.getCancelEvent());
			if (waitDone == null) waitDone = new SynchronizationPoint<>();
		}
		return waitDone;
	}
1218581
def synchronized(wrapped):
    

    @functools.wraps(wrapped)
    def wrapper(*args, **kwargs):
        self = args[0]
        with self._lock:
            return wrapped(*args, **kwargs)

    return wrapper
1091120
private final Result lockForUpgradeInterruptibly_(L locker) throws InterruptedException {
        if (Thread.interrupted()) {
            throw new InterruptedException();
        }
        Result result;
        if ((result = tryLockForUpgrade_(locker)) == Result.FAILED) {
            result = lockForUpgradeQueuedInterruptibly(locker, addUpgradeWaiter());
        }
        return result;
    }
1222778
public void clear() {
        final ReentrantLock lock = this.lock;
        lock.lock();
        try {
            int k = count;
            if (k > 0) {
                final Object[] items = this.items;
                final int putIndex = this.putIndex;
                int i = takeIndex;
                do {
                    items[i] = null;
                    if (++i == items.length) i = 0;
                } while (i != putIndex);
                takeIndex = putIndex;
                count = 0;
                if (itrs != null)
                    itrs.queueIsEmpty();
                for (; k > 0 && lock.hasWaiters(notFull); k--)
                    notFull.signal();
            }
        } finally {
            lock.unlock();
        }
    }
1129793
public synchronized void lock()
  {
    if (tc.isEntryEnabled())
      SibTr.entry(tc, "lock", this);

    boolean interrupted = false;

    // Attempt to get a lock on the mutex.
    // if we fail, then that is because the lock
    // must be held exclusively.
    while (!tryLock())
      try
      {
        // Wait for 1 second then try again.
        if (tc.isDebugEnabled())
          SibTr.debug(tc, "Waiting for lock");
        wait(1000);
      }
      catch (InterruptedException e)
      {
        // No FFDC code needed
        interrupted = true;
      }

    if (interrupted)
      Thread.currentThread().interrupt();

    if (tc.isEntryEnabled())
      SibTr.exit(tc, "lock");

  }