diff options
Diffstat (limited to 'libjava/testsuite/libjava.lang/Thread_HoldsLock.java')
-rw-r--r-- | libjava/testsuite/libjava.lang/Thread_HoldsLock.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/libjava/testsuite/libjava.lang/Thread_HoldsLock.java b/libjava/testsuite/libjava.lang/Thread_HoldsLock.java new file mode 100644 index 0000000..3a46466 --- /dev/null +++ b/libjava/testsuite/libjava.lang/Thread_HoldsLock.java @@ -0,0 +1,27 @@ +// Test that Thread.holdsLock() works. + +class Lock {} + +public class Thread_HoldsLock +{ + static Lock lock = new Lock(); + + public static void main(String args[]) throws InterruptedException + { + Thread_HoldsLock thl = new Thread_HoldsLock(); + + thl.check(); + synchronized (lock) + { + thl.check(); + } + thl.check(); + } + + public void check() + { + boolean held = Thread.currentThread().holdsLock(lock); + System.out.println(held); + } +} + |