Index: java/lang/Thread.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/lang/Thread.java,v retrieving revision 1.5 diff -u -b -B -r1.5 Thread.java --- java/lang/Thread.java 4 Feb 2004 08:45:38 -0000 1.5 +++ java/lang/Thread.java 27 Feb 2004 12:07:30 -0000 @@ -107,7 +107,7 @@ volatile ThreadGroup group; /** The object to run(), null if this is the target. */ - final Runnable toRun; + final Runnable runnable; /** The thread name, non-null. */ volatile String name; @@ -183,50 +183,55 @@ } /** - * Allocate a new Thread object, as if by - * Thread(null, toRun, fake name), where the fake name - * is "Thread-" + unique integer. + * Allocates a new Thread object. This constructor has + * the same effect as Thread(null, target, + * gname), where gname is + * a newly generated name. Automatically generated names are of the + * form "Thread-"+n, where n is an integer. * - * @param toRun the Runnable object to execute - * @see #Thread(ThreadGroup, Runnable, String) + * @param target the object whose run method is called. + * @see java.lang.Thread#Thread(java.lang.ThreadGroup, + * java.lang.Runnable, java.lang.String) */ - public Thread(Runnable toRun) + public Thread(Runnable target) { - this(null, toRun); + this(null, target); } /** - * Allocate a new Thread object, as if by - * Thread(group, toRun, fake name), where the fake name - * is "Thread-" + unique integer. + * Allocates a new Thread object. This constructor has + * the same effect as Thread(null, null, name). * - * @param group the group to put the Thread into - * @param target the Runnable object to execute - * @throws SecurityException if this thread cannot access group - * @throws IllegalThreadStateException if group is destroyed - * @see #Thread(ThreadGroup, Runnable, String) + * @param name the name of the new thread. + * @see java.lang.Thread#Thread(java.lang.ThreadGroup, + * java.lang.Runnable, java.lang.String) */ - public Thread(ThreadGroup group, Runnable toRun) + public Thread(String name) { - this(group, toRun, "Thread-" + ++numAnonymousThreadsCreated, 0); + this(null, null, name, 0); } /** - * Allocate a new Thread object, as if by - * Thread(null, null, name). + * Allocates a new Thread object. This constructor has + * the same effect as Thread(group, target, + * gname), where gname is + * a newly generated name. Automatically generated names are of the + * form "Thread-"+n, where n is an integer. * - * @param name the name for the Thread - * @throws NullPointerException if name is null + * @param group the group to put the Thread into + * @param target the Runnable object to execute + * @throws SecurityException if this thread cannot access group + * @throws IllegalThreadStateException if group is destroyed * @see #Thread(ThreadGroup, Runnable, String) */ - public Thread(String name) + public Thread(ThreadGroup group, Runnable target) { - this(null, null, name, 0); + this(group, target, "Thread-" + ++numAnonymousThreadsCreated, 0); } /** - * Allocate a new Thread object, as if by - * Thread(group, null, name). + * Allocates a new Thread object. This constructor has + * the same effect as Thread(group, null, name) * * @param group the group to put the Thread into * @param name the name for the Thread @@ -241,17 +246,17 @@ } /** - * Allocate a new Thread object, as if by - * Thread(group, null, name). + * Allocates a new Thread object. This constructor has + * the same effect as Thread(null, target, name). * - * @param toRun the Runnable object to execute + * @param target the Runnable object to execute * @param name the name for the Thread * @throws NullPointerException if name is null * @see #Thread(ThreadGroup, Runnable, String) */ - public Thread(Runnable toRun, String name) + public Thread(Runnable target, String name) { - this(null, toRun, name, 0); + this(null, target, name, 0); } /** @@ -283,9 +288,9 @@ * @see SecurityManager#checkAccess(ThreadGroup) * @see ThreadGroup#checkAccess() */ - public Thread(ThreadGroup group, Runnable toRun, String name) + public Thread(ThreadGroup group, Runnable target, String name) { - this(group, toRun, name, 0); + this(group, target, name, 0); } /** @@ -308,7 +313,7 @@ * @throws IllegalThreadStateException if group is destroyed * @since 1.4 */ - public Thread(ThreadGroup group, Runnable toRun, String name, long size) + public Thread(ThreadGroup group, Runnable target, String name, long size) { // Bypass System.getSecurityManager, for bootstrap efficiency. SecurityManager sm = Runtime.securityManager; @@ -326,7 +331,7 @@ this.group = group; // Use toString hack to detect null. this.name = name.toString(); - this.toRun = toRun; + this.runnable = target; this.stacksize = size; priority = current.priority; @@ -350,7 +355,7 @@ Thread(VMThread vmThread, String name, int priority, boolean daemon) { this.vmThread = vmThread; - this.toRun = null; + this.runnable = null; if (name == null) name = "Thread-" + ++numAnonymousThreadsCreated; this.name = name; @@ -423,6 +428,7 @@ */ public void destroy() { + throw new NoSuchMethodError(); } /** @@ -492,7 +498,7 @@ * Checks whether the current thread holds the monitor on a given object. * This allows you to do assert Thread.holdsLock(obj). * - * @param obj the object to check + * @param obj the object to test lock ownership on. * @return true if the current thread is currently synchronized on obj * @throws NullPointerException if obj is null * @since 1.4 @@ -655,14 +661,14 @@ */ public void run() { - if (toRun != null) - toRun.run(); + if (runnable != null) + runnable.run(); } /** * Set the daemon status of this Thread. If this is a daemon Thread, then * the VM may exit even if it is still running. This may only be called - * while the Thread is not running. There may be a security check, + * before the Thread starts running. There may be a security check, * checkAccess. * * @param daemon whether this should be a daemon thread or not @@ -693,7 +699,7 @@ * @see setContextClassLoader(ClassLoader) * @since 1.2 */ - public ClassLoader getContextClassLoader() + public synchronized ClassLoader getContextClassLoader() { // Bypass System.getSecurityManager, for bootstrap efficiency. SecurityManager sm = Runtime.securityManager; @@ -715,7 +721,7 @@ * @see getContextClassLoader() * @since 1.2 */ - public void setContextClassLoader(ClassLoader classloader) + public synchronized void setContextClassLoader(ClassLoader classloader) { SecurityManager sm = System.getSecurityManager(); if (sm != null)