From 6dfd8a7790da2956f92e6abc1266206121f70388 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Tue, 20 Jun 2000 13:30:14 +0000 Subject: ThreadGroup.java: Merged with classpath. 2000-06-20 Bryce McKinlay * java/lang/ThreadGroup.java: Merged with classpath. * prims.cc (_Jv_RunMain): Don't use ain_group'. * gnu/gcj/runtime/FirstThread.java: Remove ThreadGroup constructor argument. * java/lang/Thread.java (Thread): Bootstrap initial thread from ThreadGroup.root if Thread.currentThread is null. Honour the ThreadGroup's max priority setting. From-SVN: r34615 --- libjava/java/lang/Thread.java | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'libjava/java/lang/Thread.java') diff --git a/libjava/java/lang/Thread.java b/libjava/java/lang/Thread.java index 0d11337..8be7f60 100644 --- a/libjava/java/lang/Thread.java +++ b/libjava/java/lang/Thread.java @@ -198,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. @@ -218,8 +220,7 @@ public class Thread implements Runnable throw new NullPointerException (); name = n; - group = g; - g.add(this); + group.add(this); runnable = r; data = null; @@ -230,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 { -- cgit v1.1