[kaffe] CVS kaffe (dalibor): Implemented Thread.holdsLock
Kaffe CVS
cvs-commits at kaffe.org
Wed Jul 14 05:53:32 PDT 2004
PatchSet 4967
Date: 2004/07/14 12:43:49
Author: dalibor
Branch: HEAD
Tag: (none)
Log:
Implemented Thread.holdsLock
2004-07-13 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/java/lang/Thread.java
(holdsLock): Implemented.
Reported by: Jim Huang <jserv at kaffe.org>
Members:
ChangeLog:1.2531->1.2532
libraries/javalib/java/lang/Thread.java:1.46->1.47
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2531 kaffe/ChangeLog:1.2532
--- kaffe/ChangeLog:1.2531 Wed Jul 14 11:11:52 2004
+++ kaffe/ChangeLog Wed Jul 14 12:43:49 2004
@@ -1,5 +1,12 @@
2004-07-13 Dalibor Topic <robilad at kaffe.org>
+ * libraries/javalib/java/lang/Thread.java
+ (holdsLock): Implemented.
+
+ Reported by: Jim Huang <jserv at kaffe.org>
+
+2004-07-13 Dalibor Topic <robilad at kaffe.org>
+
* config/sparc/jit-sparc.def:
Fixed stray LOUT without closing brace.
Index: kaffe/libraries/javalib/java/lang/Thread.java
diff -u kaffe/libraries/javalib/java/lang/Thread.java:1.46 kaffe/libraries/javalib/java/lang/Thread.java:1.47
--- kaffe/libraries/javalib/java/lang/Thread.java:1.46 Sun Jul 11 13:33:25 2004
+++ kaffe/libraries/javalib/java/lang/Thread.java Wed Jul 14 12:43:51 2004
@@ -484,4 +484,19 @@
context = cl;
}
+public static boolean holdsLock(Object obj) {
+ // use obj.notify to check if the current thread holds
+ // the monitor of the object.
+ // if it doesn't, notify will throw an exception.
+ try {
+ obj.notify();
+ // okay, current thread holds lock
+ return true;
+ }
+ catch (IllegalMonitorStateException e) {
+ // it doesn't hold the lock
+ return false;
+ }
+}
+
}
More information about the kaffe
mailing list