Code example for ReentrantLock

Methods: lock, unlock

0
    } 
 
    @Override 
    public Weather loadDataFromNetwork() throws Exception { 
        try { 
            reentrantLock.lock(); 
            loadDataFromNetworkHasBeenExecuted.signal(); 
        } finally { 
            reentrantLock.unlock(); 
        } 
        return new Weather(); 
    } 
 
    public void await(long timeout) throws InterruptedException { 
        try { 
            reentrantLock.lock(); 
            loadDataFromNetworkHasBeenExecuted.await(timeout, 
                TimeUnit.MILLISECONDS); 
        } finally { 
            reentrantLock.unlock(); 
        }