[cp-patches] FYI: Handle thread state

Jeroen Frijters jeroen at sumatra.nl
Thu Jun 29 08:33:22 UTC 2006


Andrew John Hughes wrote:
> This patch puts a bit more into thread state handling.

I apologize for being blunt, but this patch is unacceptable. It doesn't
cover all cases, it's incorrect and inefficient.

I really think it's best to leave determining the thread state up to
VMThread, except of course that there still needs to be support for
threads that don't yet (or no longer) have a VMThread.

Below is a patch that shows what I think getState should look like.

Regards,
Jeroen

Index: java/lang/Thread.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Thread.java,v
retrieving revision 1.26
diff -u -r1.26 Thread.java
--- java/lang/Thread.java	27 Jun 2006 21:57:29 -0000	1.26
+++ java/lang/Thread.java	29 Jun 2006 08:30:11 -0000
@@ -1239,7 +1239,11 @@
   public String getState()
   {
     VMThread t = vmThread;
-    return t == null ? null : t.getState();
+    if (t != null)
+      return t.getState();
+    if (group == null)
+      return "TERMINATED";
+    return "NEW";
   }
 
   /**



More information about the Classpath-patches mailing list