author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Fri, 03 Apr 2020 16:32:36 +0200 | |
changeset 416 | 9ed8788a1a4e |
permissions | -rw-r--r-- |
1 package org.apidesign.reentrant;
3 import java.util.concurrent.locks.ReentrantLock;
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 }
14 @Override
15 public void lockInterruptibly() throws InterruptedException {
16 if (isHeldByCurrentThread()) {
17 throw new IllegalStateException("Attempt to reentrant lock");
18 }
19 super.lockInterruptibly();
20 }
22 }