--- old/src/java.base/share/classes/java/lang/Thread.java 2018-03-29 16:25:00.419300268 -0700 +++ new/src/java.base/share/classes/java/lang/Thread.java 2018-03-29 16:25:00.167297999 -0700 @@ -188,7 +188,7 @@ * not specify a stack size. It is up to the VM to do whatever it * likes with this number; some VMs will ignore it. */ - private long stackSize; + private final long stackSize; /* * JVM-private state that persists after native thread termination. @@ -198,20 +198,20 @@ /* * Thread ID */ - private long tid; + private final long tid; /* For generating thread ID */ private static long threadSeqNumber; + private static synchronized long nextThreadID() { + return ++threadSeqNumber; + } + /* * Java thread status for tools, default indicates thread 'not yet started' */ private volatile int threadStatus; - private static synchronized long nextThreadID() { - return ++threadSeqNumber; - } - /** * The argument supplied to the current call to * java.util.concurrent.locks.LockSupport.park. @@ -377,15 +377,6 @@ public static void onSpinWait() {} /** - * Initializes a Thread with the current AccessControlContext. - * @see #init(ThreadGroup,Runnable,String,long,AccessControlContext,boolean) - */ - private void init(ThreadGroup g, Runnable target, String name, - long stackSize) { - init(g, target, name, stackSize, null, true); - } - - /** * Initializes a Thread. * * @param g the Thread group @@ -398,9 +389,9 @@ * @param inheritThreadLocals if {@code true}, inherit initial values for * inheritable thread-locals from the constructing thread */ - private void init(ThreadGroup g, Runnable target, String name, - long stackSize, AccessControlContext acc, - boolean inheritThreadLocals) { + private Thread(ThreadGroup g, Runnable target, String name, + long stackSize, AccessControlContext acc, + boolean inheritThreadLocals) { if (name == null) { throw new NullPointerException("name cannot be null"); } @@ -418,8 +409,8 @@ g = security.getThreadGroup(); } - /* If the security doesn't have a strong opinion of the matter - use the parent thread group. */ + /* If the security manager doesn't have a strong opinion + on the matter, use the parent thread group. */ if (g == null) { g = parent.getThreadGroup(); } @@ -458,7 +449,7 @@ this.stackSize = stackSize; /* Set thread ID */ - tid = nextThreadID(); + this.tid = nextThreadID(); } /** @@ -481,7 +472,7 @@ * {@code "Thread-"+}n, where n is an integer. */ public Thread() { - init(null, null, "Thread-" + nextThreadNum(), 0); + this(null, null, "Thread-" + nextThreadNum(), 0); } /** @@ -497,7 +488,7 @@ * nothing. */ public Thread(Runnable target) { - init(null, target, "Thread-" + nextThreadNum(), 0); + this(null, target, "Thread-" + nextThreadNum(), 0); } /** @@ -506,7 +497,7 @@ * This is not a public constructor. */ Thread(Runnable target, AccessControlContext acc) { - init(null, target, "Thread-" + nextThreadNum(), 0, acc, false); + this(null, target, "Thread-" + nextThreadNum(), 0, acc, false); } /** @@ -533,7 +524,7 @@ * thread group */ public Thread(ThreadGroup group, Runnable target) { - init(group, target, "Thread-" + nextThreadNum(), 0); + this(group, target, "Thread-" + nextThreadNum(), 0); } /** @@ -545,7 +536,7 @@ * the name of the new thread */ public Thread(String name) { - init(null, null, name, 0); + this(null, null, name, 0); } /** @@ -569,7 +560,7 @@ * thread group */ public Thread(ThreadGroup group, String name) { - init(group, null, name, 0); + this(group, null, name, 0); } /** @@ -585,7 +576,7 @@ * the name of the new thread */ public Thread(Runnable target, String name) { - init(null, target, name, 0); + this(null, target, name, 0); } /** @@ -633,7 +624,7 @@ * thread group or cannot override the context class loader methods. */ public Thread(ThreadGroup group, Runnable target, String name) { - init(group, target, name, 0); + this(group, target, name, 0); } /** @@ -712,7 +703,7 @@ */ public Thread(ThreadGroup group, Runnable target, String name, long stackSize) { - init(group, target, name, stackSize); + this(group, target, name, stackSize, null, true); } /** @@ -768,7 +759,7 @@ */ public Thread(ThreadGroup group, Runnable target, String name, long stackSize, boolean inheritThreadLocals) { - init(group, target, name, stackSize, null, inheritThreadLocals); + this(group, target, name, stackSize, null, inheritThreadLocals); } /**