samples/reentrant/src/org/apidesign/reentrant/NonReentrantLock.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 21:30:10 +0100
changeset 409 40cabcdcd2be
permissions -rw-r--r--
Updating to NBMs from NetBeans 8.0.1 as some of them are required to run on JDK8
     1 package org.apidesign.reentrant;
     2 
     3 import java.util.concurrent.locks.ReentrantLock;
     4 
     5 final class NonReentrantLock extends ReentrantLock {
     6     @Override
     7     public void lock() {
     8         if (isHeldByCurrentThread()) {
     9             throw new IllegalStateException("Attempt to reentrant lock");
    10         }
    11         super.lock();
    12     }
    13 
    14     @Override
    15     public void lockInterruptibly() throws InterruptedException {
    16         if (isHeldByCurrentThread()) {
    17             throw new IllegalStateException("Attempt to reentrant lock");
    18         }
    19         super.lockInterruptibly();
    20     }
    21     
    22 }