mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-26 12:23:59 +08:00
Thread.java: Reordered fields...
2004-02-05 Michael Koch <konqueror@gmx.de> * java/lang/Thread.java: Reordered fields, reformated much code, no functional changes, some variables renamed, javadoc comments merged. From-SVN: r77322
This commit is contained in:
parent
6d0c7d7b6a
commit
5ad136540e
@ -1,3 +1,9 @@
|
||||
2004-02-05 Michael Koch <konqueror@gmx.de>
|
||||
|
||||
* java/lang/Thread.java: Reordered fields, reformated much code,
|
||||
no functional changes, some variables renamed, javadoc comments
|
||||
merged.
|
||||
|
||||
2004-02-05 Michael Koch <konqueror@gmx.de>
|
||||
|
||||
* java/util/zip/Deflater.java,
|
||||
|
@ -89,14 +89,42 @@ import gnu.gcj.RawData;
|
||||
*/
|
||||
public class Thread implements Runnable
|
||||
{
|
||||
/** The maximum priority for a Thread. */
|
||||
public final static int MAX_PRIORITY = 10;
|
||||
|
||||
/** The minimum priority for a Thread. */
|
||||
public final static int MIN_PRIORITY = 1;
|
||||
public static final int MIN_PRIORITY = 1;
|
||||
|
||||
/** The priority a Thread gets by default. */
|
||||
public final static int NORM_PRIORITY = 5;
|
||||
public static final int NORM_PRIORITY = 5;
|
||||
|
||||
/** The maximum priority for a Thread. */
|
||||
public static final int MAX_PRIORITY = 10;
|
||||
|
||||
/**
|
||||
* The group this thread belongs to. This is set to null by
|
||||
* ThreadGroup.removeThread when the thread dies.
|
||||
*/
|
||||
ThreadGroup group;
|
||||
|
||||
/** The thread name, non-null. */
|
||||
String name;
|
||||
|
||||
/** The object to run(), null if this is the target. */
|
||||
private Runnable runnable;
|
||||
|
||||
/** The thread priority, 1 to 10. */
|
||||
private int priority;
|
||||
|
||||
private boolean daemon_flag;
|
||||
boolean interrupt_flag;
|
||||
private boolean alive_flag;
|
||||
private boolean startable_flag;
|
||||
private ClassLoader context_class_loader;
|
||||
|
||||
// This describes the top-most interpreter frame for this thread.
|
||||
RawData interp_frame;
|
||||
|
||||
// Our native data - points to an instance of struct natThread.
|
||||
private Object data;
|
||||
|
||||
|
||||
/**
|
||||
* Get the number of active threads in the current Thread's ThreadGroup.
|
||||
@ -120,9 +148,9 @@ public class Thread implements Runnable
|
||||
*/
|
||||
public final void checkAccess()
|
||||
{
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
if (s != null)
|
||||
s.checkAccess(this);
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkAccess(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,9 +201,9 @@ public class Thread implements Runnable
|
||||
* @see #activeCount()
|
||||
* @see SecurityManager#checkAccess(ThreadGroup)
|
||||
*/
|
||||
public static int enumerate (Thread[] threads)
|
||||
public static int enumerate(Thread[] array)
|
||||
{
|
||||
return currentThread().group.enumerate(threads);
|
||||
return currentThread().group.enumerate(array);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,6 +241,7 @@ public class Thread implements Runnable
|
||||
* Return true if this Thread holds the object's lock, false otherwise.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
@ -258,7 +287,7 @@ public class Thread implements Runnable
|
||||
* Determine whether the given Thread has been interrupted, but leave
|
||||
* the <i>interrupted status</i> alone in the process.
|
||||
*
|
||||
* @return whether the current Thread has been interrupted
|
||||
* @return whether the Thread has been interrupted
|
||||
* @see #interrupted()
|
||||
*/
|
||||
public boolean isInterrupted()
|
||||
@ -306,9 +335,9 @@ public class Thread implements Runnable
|
||||
* @throws InterruptedException if the Thread is interrupted; it's
|
||||
* <i>interrupted status</i> will be cleared
|
||||
*/
|
||||
public final void join (long timeout) throws InterruptedException
|
||||
public final void join(long ms) throws InterruptedException
|
||||
{
|
||||
join (timeout, 0);
|
||||
join(ms, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -327,13 +356,15 @@ public class Thread implements Runnable
|
||||
* @throws IllegalArgumentException if ns is invalid
|
||||
* @XXX A ThreadListener would be nice, to make this efficient.
|
||||
*/
|
||||
public final native void join (long timeout, int nanos)
|
||||
public final native void join(long ms, int ns)
|
||||
throws InterruptedException;
|
||||
|
||||
/**
|
||||
* Resume a suspended thread.
|
||||
*
|
||||
* @see #resume()
|
||||
* @throws SecurityException if you cannot resume the Thread
|
||||
* @see #checkAccess()
|
||||
* @see #suspend()
|
||||
* @deprecated pointless, since suspend is deprecated
|
||||
*/
|
||||
public final native void resume();
|
||||
@ -412,10 +443,10 @@ public class Thread implements Runnable
|
||||
if (context_class_loader == null)
|
||||
context_class_loader = ClassLoader.getSystemClassLoader();
|
||||
|
||||
SecurityManager s = System.getSecurityManager();
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
// FIXME: we can't currently find the caller's class loader.
|
||||
ClassLoader callers = null;
|
||||
if (s != null && callers != null)
|
||||
if (sm != null && callers != null)
|
||||
{
|
||||
// See if the caller's class loader is the same as or an
|
||||
// ancestor of this thread's class loader.
|
||||
@ -427,7 +458,7 @@ public class Thread implements Runnable
|
||||
}
|
||||
|
||||
if (callers != context_class_loader)
|
||||
s.checkPermission (new RuntimePermission ("getClassLoader"));
|
||||
sm.checkPermission(new RuntimePermission("getClassLoader"));
|
||||
}
|
||||
|
||||
return context_class_loader;
|
||||
@ -442,17 +473,17 @@ public class Thread implements Runnable
|
||||
* class loader is not null or an ancestor of this thread's context class
|
||||
* loader.
|
||||
*
|
||||
* @return the context class loader
|
||||
* @param classloader the new context class loader
|
||||
* @throws SecurityException when permission is denied
|
||||
* @see setContextClassLoader(ClassLoader)
|
||||
* @see getContextClassLoader()
|
||||
* @since 1.2
|
||||
*/
|
||||
public synchronized void setContextClassLoader(ClassLoader cl)
|
||||
public synchronized void setContextClassLoader(ClassLoader classloader)
|
||||
{
|
||||
SecurityManager s = System.getSecurityManager ();
|
||||
if (s != null)
|
||||
s.checkPermission (new RuntimePermission ("setContextClassLoader"));
|
||||
context_class_loader = cl;
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (sm != null)
|
||||
sm.checkPermission(new RuntimePermission("setContextClassLoader"));
|
||||
context_class_loader = classloader;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -463,14 +494,14 @@ public class Thread implements Runnable
|
||||
* @throws NullPointerException if name is null
|
||||
* @throws SecurityException if you cannot modify this Thread
|
||||
*/
|
||||
public final void setName (String n)
|
||||
public final void setName(String name)
|
||||
{
|
||||
checkAccess();
|
||||
// The Class Libraries book says ``threadName cannot be null''. I
|
||||
// take this to mean NullPointerException.
|
||||
if (n == null)
|
||||
if (name == null)
|
||||
throw new NullPointerException();
|
||||
name = n;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -502,9 +533,9 @@ public class Thread implements Runnable
|
||||
* @see #notify()
|
||||
* @see #wait(long)
|
||||
*/
|
||||
public static void sleep (long timeout) throws InterruptedException
|
||||
public static void sleep(long ms) throws InterruptedException
|
||||
{
|
||||
sleep (timeout, 0);
|
||||
sleep(ms, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -861,12 +892,12 @@ public class Thread implements Runnable
|
||||
* Returns a string representation of this thread, including the
|
||||
* thread's name, priority, and thread group.
|
||||
*
|
||||
* @return a string representation of this thread.
|
||||
* @return a human-readable String representing this Thread
|
||||
*/
|
||||
public String toString()
|
||||
{
|
||||
return "Thread[" + name + "," + priority + "," +
|
||||
(group == null ? "" : group.getName()) + "]";
|
||||
return ("Thread[" + name + "," + priority + ","
|
||||
+ (group == null ? "" : group.getName()) + "]");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -875,20 +906,4 @@ public class Thread implements Runnable
|
||||
*/
|
||||
public static native void yield ();
|
||||
|
||||
// Private data.
|
||||
ThreadGroup group;
|
||||
String name;
|
||||
private Runnable runnable;
|
||||
private int priority;
|
||||
private boolean daemon_flag;
|
||||
boolean interrupt_flag;
|
||||
private boolean alive_flag;
|
||||
private boolean startable_flag;
|
||||
private ClassLoader context_class_loader;
|
||||
|
||||
// This describes the top-most interpreter frame for this thread.
|
||||
RawData interp_frame;
|
||||
|
||||
// Our native data - points to an instance of struct natThread.
|
||||
private Object data;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user