1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/reentrant/src/org/apidesign/reentrant/NonReentrantLock.java Sat Jun 14 09:54:36 2008 +0200
1.3 @@ -0,0 +1,22 @@
1.4 +package org.apidesign.reentrant;
1.5 +
1.6 +import java.util.concurrent.locks.ReentrantLock;
1.7 +
1.8 +final class NonReentrantLock extends ReentrantLock {
1.9 + @Override
1.10 + public void lock() {
1.11 + if (isHeldByCurrentThread()) {
1.12 + throw new IllegalStateException("Attempt to reentrant lock");
1.13 + }
1.14 + super.lock();
1.15 + }
1.16 +
1.17 + @Override
1.18 + public void lockInterruptibly() throws InterruptedException {
1.19 + if (isHeldByCurrentThread()) {
1.20 + throw new IllegalStateException("Attempt to reentrant lock");
1.21 + }
1.22 + super.lockInterruptibly();
1.23 + }
1.24 +
1.25 +}