Java tutorial
//package com.java2s; import java.util.concurrent.locks.ReentrantLock; public class Main { public static void requireLock(ReentrantLock lock) { if (!lock.isHeldByCurrentThread()) { throw new RuntimeException( "Lock is not held by current thread: thread-name = " + Thread.currentThread().getName()); } } }