summaryrefslogtreecommitdiff
path: root/java/lang/ThreadGroup.java
diff options
context:
space:
mode:
authorJeroen Frijters <jeroen@sumatra.nl>2006-07-01 13:00:21 +0000
committerJeroen Frijters <jeroen@sumatra.nl>2006-07-01 13:00:21 +0000
commit2f65b82887113c7b39c34f415ec690b20074bd06 (patch)
tree4f938af3469d7987a6c3623b61f7711396141bc3 /java/lang/ThreadGroup.java
parent62c8b59b6f917d9ce704f7a6937cb6edd2824491 (diff)
downloadclasspath-2f65b82887113c7b39c34f415ec690b20074bd06.tar.gz
2006-07-01 Jeroen Frijters <jeroen@frijters.net>
* java/lang/ThreadGroup.java (getThreadFromId, getThreadFromIdImpl): New methods.
Diffstat (limited to 'java/lang/ThreadGroup.java')
-rw-r--r--java/lang/ThreadGroup.java39
1 files changed, 39 insertions, 0 deletions
diff --git a/java/lang/ThreadGroup.java b/java/lang/ThreadGroup.java
index daddf43e3..00f2f8ec4 100644
--- a/java/lang/ThreadGroup.java
+++ b/java/lang/ThreadGroup.java
@@ -749,4 +749,43 @@ public class ThreadGroup implements UncaughtExceptionHandler
parent.removeGroup(this);
}
}
+
+ /*
+ * Helper method for the VM. Find a Thread by its Id.
+ *
+ * @param id The Thread Id.
+ * @return Thread object or null if thread doesn't exist.
+ */
+ static Thread getThreadFromId(long id)
+ {
+ return root.getThreadFromIdImpl(id);
+ }
+
+ private Thread getThreadFromIdImpl(long id)
+ {
+ synchronized (threads)
+ {
+ for (int i = 0; i < threads.size(); i++)
+ {
+ Thread t = (Thread) threads.get(i);
+ if (t.getId() == id)
+ return t;
+ }
+ }
+ Vector groups = this.groups;
+ if (groups != null)
+ {
+ synchronized (groups)
+ {
+ for (int i = 0; i < groups.size(); i++)
+ {
+ ThreadGroup g = (ThreadGroup) groups.get(i);
+ Thread t = g.getThreadFromIdImpl(id);
+ if (t != null)
+ return t;
+ }
+ }
+ }
+ return null;
+ }
} // class ThreadGroup