Thread_HoldsLock.java: New test case.
authorBryce McKinlay <mckinlay@redhat.com>
Tue, 27 Jul 2004 22:04:37 +0000 (22:04 +0000)
committerBryce McKinlay <bryce@gcc.gnu.org>
Tue, 27 Jul 2004 22:04:37 +0000 (23:04 +0100)
2004-07-27  Bryce McKinlay  <mckinlay@redhat.com>

* testsuite/libjava.lang/Thread_HoldsLock.java: New test case.
* testsuite/libjava.lang/Thread_HoldsLock.out: New.

From-SVN: r85234

libjava/ChangeLog
libjava/testsuite/libjava.lang/Thread_HoldsLock.java [new file with mode: 0644]
libjava/testsuite/libjava.lang/Thread_HoldsLock.out [new file with mode: 0644]

index ce46e07bdf6cc3ea0d1657c6d6e312730d1fcfd1..2ad34fae6e48f6c2aaa1d4fc0433a3a6db3b1833 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-27  Bryce McKinlay  <mckinlay@redhat.com>
+
+       * testsuite/libjava.lang/Thread_HoldsLock.java: New test case.
+       * testsuite/libjava.lang/Thread_HoldsLock.out: New.     
+
 2004-07-27  Bryce McKinlay  <mckinlay@redhat.com>
 
        * java/io/File.java (toURI): Throw RuntimeException, not 
diff --git a/libjava/testsuite/libjava.lang/Thread_HoldsLock.java b/libjava/testsuite/libjava.lang/Thread_HoldsLock.java
new file mode 100644 (file)
index 0000000..3a46466
--- /dev/null
@@ -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);
+  }
+}
+
diff --git a/libjava/testsuite/libjava.lang/Thread_HoldsLock.out b/libjava/testsuite/libjava.lang/Thread_HoldsLock.out
new file mode 100644 (file)
index 0000000..eed4037
--- /dev/null
@@ -0,0 +1,3 @@
+false
+true
+false