OSDN Git Service

2000-06-21 Bryce McKinlay <bryce@albatross.co.nz>
[pf3gnuchains/gcc-fork.git] / libjava / java / lang / Thread.java
index a731b0a..5b78963 100644 (file)
@@ -10,8 +10,6 @@ details.  */
 
 package java.lang;
 
-import gnu.gcj.RawData;
-
 /**
  * @author Tom Tromey <tromey@cygnus.com>
  * @date August 24, 1998 
@@ -200,19 +198,21 @@ public class Thread implements Runnable
 
   public Thread (ThreadGroup g, Runnable r, String n)
   {
-    // Note that CURRENT can be null when we are creating the very
-    // first thread.  That's why we check it below.
     Thread current = currentThread ();
-
-    if (g != null)
+          
+    if (g == null)
       {
-       // If CURRENT is null, then we are creating the first thread.
-       // In this case we don't do the security check.
-       if (current != null)
-         g.checkAccess();
+       // If CURRENT is null, then we are bootstrapping the first thread. 
+       // Use ThreadGroup.root, the main threadgroup.
+       if (current == null)
+         group = ThreadGroup.root;
+       else
+         group = current.getThreadGroup();
       }
     else
-      g = current.getThreadGroup();
+      group = g;
+      
+    group.checkAccess();
 
     // The Class Libraries book says ``threadName cannot be null''.  I
     // take this to mean NullPointerException.
@@ -220,8 +220,7 @@ public class Thread implements Runnable
       throw new NullPointerException ();
 
     name = n;
-    group = g;
-    g.add(this);
+    group.addThread(this);
     runnable = r;
 
     data = null;
@@ -232,7 +231,9 @@ public class Thread implements Runnable
     if (current != null)
       {
        daemon_flag = current.isDaemon();
-       priority = current.getPriority();
+        int gmax = group.getMaxPriority();
+       int pri = current.getPriority();
+       priority = (gmax < pri ? gmax : pri);
       }
     else
       {
@@ -292,7 +293,7 @@ public class Thread implements Runnable
   private boolean startable_flag;
 
   // Our native data.
-  private RawData data;
+  private Object data;
 
   // Next thread number to assign.
   private static int nextThreadNumber = 0;