Code example for ReentrantLock

Methods: isHeldByCurrentThread

0
        } 
    } 
 
    // Asserts that |lock| is held by the current thread. 
    public static void assertLockIsHeld(ReentrantLock lock) {
        if (!lock.isHeldByCurrentThread()) {
            throw new RuntimeException("Assert: mandatory lock isn't held by current thread");
        } 
    } 
 
    // Asserts that |lock| is not held by the current thread. 
    public static void assertLockIsNotHeld(ReentrantLock lock) {
        if (lock.isHeldByCurrentThread()) {
            throw new RuntimeException("Assert: lock is held by current thread but shouldn't be");
        } 
    } 
 
    private static final String HEX = "0123456789abcdef";
 
    public static String getHex(byte[] raw) {
        if (raw == null) {