Andrew John Hughes wrote:
> The attached patch fixes the initialization of the thread IDs
> in java.lang.Thread so that it starts at 1.  0 is not a valid
> thread ID, and was rightly being thrown out by the managment stuff.

You just beat me to it!

I hope you don't mind but I checked in my slightly more efficient fix.
This way Thread doesn't need to have a static initializer method.

Regards,
Jeroen

2006-07-01  Jeroen Frijters  <[EMAIL PROTECTED]>

        * java/lang/Thread.java:
        Make thread IDs start from 1 in a more efficient way.
Index: java/lang/Thread.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/lang/Thread.java,v
retrieving revision 1.30
diff -u -r1.30 Thread.java
--- java/lang/Thread.java       1 Jul 2006 11:58:39 -0000       1.30
+++ java/lang/Thread.java       1 Jul 2006 12:54:07 -0000
@@ -147,8 +147,8 @@
   /** The next thread number to use. */
   private static int numAnonymousThreadsCreated;
   
-  /** The next thread ID to use.  */
-  private static long nextThreadId = 1;
+  /** Used to generate the next thread ID to use.  */
+  private static long totalThreadsCreated;
 
   /** The default exception handler.  */
   private static UncaughtExceptionHandler defaultHandler;
@@ -367,7 +367,7 @@
     
     synchronized (Thread.class)
       {
-        this.threadId = nextThreadId++;
+        this.threadId = ++totalThreadsCreated;
       }
 
     priority = current.priority;
@@ -414,7 +414,7 @@
     contextClassLoaderIsSystemClassLoader = true;
     synchronized (Thread.class)
       {
-       this.threadId = nextThreadId++;
+       this.threadId = ++totalThreadsCreated;
       }
   }
 

Reply via email to