Thread.setDaemon() patch

Mark Wielaard mark@klomp.org
Sat Oct 5 15:08:00 GMT 2002


Hi,

Here is a small patch that fixes a corner case in setDaemon(). You may
not call setDaemon() after the Thread is started even when it is already
finished and not alive anymore.

2002-10-06  Mark Wielaard  <mark@klomp.org>

    * java/lang/Thread.java (setDaemon): Check startable_flag,
    not isAlive().

OK to commit?

Cheers,

Mark

--- java/lang/Thread.java	29 Aug 2002 17:53:28 -0000	1.23
+++ java/lang/Thread.java	5 Oct 2002 21:50:51 -0000
@@ -137,7 +137,7 @@
   public final void setDaemon (boolean status)
   {
     checkAccess ();
-    if (isAlive ())
+    if (!startable_flag)
       throw new IllegalThreadStateException ();
     daemon_flag = status;
   }



More information about the Java-patches mailing list