diff options
Diffstat (limited to 'libjava/classpath/java/lang/ThreadGroup.java')
-rw-r--r-- | libjava/classpath/java/lang/ThreadGroup.java | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/libjava/classpath/java/lang/ThreadGroup.java b/libjava/classpath/java/lang/ThreadGroup.java index 7fbef88..00f2f8e 100644 --- a/libjava/classpath/java/lang/ThreadGroup.java +++ b/libjava/classpath/java/lang/ThreadGroup.java @@ -66,7 +66,7 @@ public class ThreadGroup implements UncaughtExceptionHandler static boolean had_uncaught_exception; /** The parent thread group. */ - private final ThreadGroup parent; + final ThreadGroup parent; /** The group name, non-null. */ final String name; @@ -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 |