Code example for ReentrantLock

Methods: newCondition

0
 
    /** Wait queue for waiting takes */ 
    private final Condition notEmpty = takeLock.newCondition();
 
    /** Lock held by put, offer, etc */ 
    private final ReentrantLock putLock = new ReentrantLock();
 
    /** Wait queue for waiting puts */ 
    private final Condition notFull = putLock.newCondition();
 
    /** 
     * Signals a waiting take. Called only from put/offer (which do not 
     * otherwise ordinarily lock takeLock.) 
     */ 
    private void signalNotEmpty() { 
        final ReentrantLock takeLock = this.takeLock;
        takeLock.lock();
        try { 
            notEmpty.signal();
        } finally { 
            takeLock.unlock();