package java.lang;
-import gnu.gcj.RawData;
-
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date August 24, 1998
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.
throw new NullPointerException ();
name = n;
- group = g;
- g.add(this);
+ group.addThread(this);
runnable = r;
data = null;
if (current != null)
{
daemon_flag = current.isDaemon();
- priority = current.getPriority();
+ int gmax = group.getMaxPriority();
+ int pri = current.getPriority();
+ priority = (gmax < pri ? gmax : pri);
}
else
{
private boolean startable_flag;
// Our native data.
- private RawData data;
+ private Object data;
// Next thread number to assign.
private static int nextThreadNumber = 0;