Code example for ReentrantLock

Methods: newCondition

0
package org.wso2.siddhi.core.persistence; 
 
import java.util.concurrent.locks.Condition; 
import java.util.concurrent.locks.ReentrantLock; 
 
 
public class ThreadBarrier { 
    private boolean open = true;
     
    private final ReentrantLock lock = new ReentrantLock();
    private final Condition threadSwitchCondition  = lock.newCondition();
     
    public void pass() { 
        lock.lock();
        if(!open){
//            threadSwitchCondition.awaitUninterruptibly(); 
            try { 
                threadSwitchCondition.await();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } 
        } 
        lock.unlock();
     } 
Connect your IDE to all the code out there  Get Codota for Java