Code example for ReentrantLock

Methods: lock, unlock

0
 
    /** 
     * Lock to prevent both puts and takes. 
     */ 
    void fullyLock() { 
        putLock.lock();
        takeLock.lock();
    } 
 
    /** 
     * Unlock to allow both puts and takes. 
     */ 
    void fullyUnlock() { 
        takeLock.unlock();
        putLock.unlock();
    } 
 
//     /** 
//      * Tells whether both locks are held by current thread. 
//      */ 
//     boolean isFullyLocked() {