author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:54:36 +0200 | |
changeset 111 | 3905a2e66b9b |
permissions | -rw-r--r-- |
jtulach@111 | 1 |
package org.apidesign.reentrant; |
jtulach@111 | 2 |
|
jtulach@111 | 3 |
import java.util.concurrent.locks.ReentrantLock; |
jtulach@111 | 4 |
|
jtulach@111 | 5 |
final class NonReentrantLock extends ReentrantLock { |
jtulach@111 | 6 |
@Override |
jtulach@111 | 7 |
public void lock() { |
jtulach@111 | 8 |
if (isHeldByCurrentThread()) { |
jtulach@111 | 9 |
throw new IllegalStateException("Attempt to reentrant lock"); |
jtulach@111 | 10 |
} |
jtulach@111 | 11 |
super.lock(); |
jtulach@111 | 12 |
} |
jtulach@111 | 13 |
|
jtulach@111 | 14 |
@Override |
jtulach@111 | 15 |
public void lockInterruptibly() throws InterruptedException { |
jtulach@111 | 16 |
if (isHeldByCurrentThread()) { |
jtulach@111 | 17 |
throw new IllegalStateException("Attempt to reentrant lock"); |
jtulach@111 | 18 |
} |
jtulach@111 | 19 |
super.lockInterruptibly(); |
jtulach@111 | 20 |
} |
jtulach@111 | 21 |
|
jtulach@111 | 22 |
} |