Code example for ReentrantLock

Methods: lock, unlock

0
        // ---------------------------------------------------- 
 
        @Override 
        protected void loadBitmapAsynchronously(DataUnderTest octo, ImageView thumbImageView, String tempThumbnailImageFileName) {
            super.loadBitmapAsynchronously(octo, thumbImageView, tempThumbnailImageFileName);
            reentrantLock.lock();
            try { 
                loadBitmapHasBeenCalled = true;
                loadBitmapHasBeenCalledCondition.signal();
            } finally { 
                reentrantLock.unlock();
            } 
        } 
 
        public void await(long millisecond) throws InterruptedException {
            reentrantLock.lock();
            try { 
                loadBitmapHasBeenCalledCondition.await(millisecond, TimeUnit.MILLISECONDS);
            } finally { 
                reentrantLock.unlock();
            }