then the channel will be closed, the thread's interrupt
status will be set, and the thread will receive a java.nio.channels.ClosedByInterruptException.
If this thread is blocked in a java.nio.channels.Selector
then the thread's interrupt status will be set and it will return
immediately from the selection operation, possibly with a non-zero
value, just as if the selector's wakeup method were invoked.
If none of the previous conditions hold then this thread's interrupt
status will be set.
isAlive
public final native boolean isAlive(
)
Tests if this thread is alive. A thread is alive if it has
been started and has not yet died.
isDaemon
public final boolean isDaemon(
)
Tests if this thread is a daemon thread.
isInterrupted
public boolean isInterrupted(
)
Tests whether this thread has been interrupted. The interrupted
status of the thread is unaffected by this method.
join
public final void join(
)
throws
InterruptedException
Waits for this thread to die.
join
public final synchronized void join(
long millis
)
throws
InterruptedException
Waits at most millis milliseconds for this thread to
die. A timeout of 0 means to wait forever.
join
public final synchronized void join(
long millis,
int nanos
)
throws
InterruptedException
Waits at most millis milliseconds plus
nanos nanoseconds for this thread to die.
resume
public final void resume(
)
Resumes a suspended thread.
First, the checkAccess method of this thread is called
with no arguments. This may result in throwing a
SecurityException (in the current thread).
If the thread is alive but suspended, it is resumed and is
permitted to make progress in its execution.
run
public void run(
)
If this thread was constructed using a separate
Runnable run object, then that
Runnable object's run method is called;
otherwise, this method does nothing and returns.
Subclasses of Thread should override this method.
setContextClassLoader
public void setContextClassLoader(
ClassLoader cl
)
Sets the context ClassLoader for this Thread. The context
ClassLoader can be set when a thread is created, and allows
the creator of the thread to provide the appropriate class loader
to code running in the thread when loading classes and resources.
First, if there is a security manager, its checkPermission
method is called with a
RuntimePermission("setContextClassLoader") permission
to see if it's ok to set the context ClassLoader..
setDaemon
public final void setDaemon(
boolean on
)
Marks this thread as either a daemon thread or a user thread. The
Java Virtual Machine exits when the only threads running are all
daemon threads.
This method must be called before the thread is started.
This method first calls the checkAccess method
of this thread
with no arguments. This may result in throwing a
SecurityException (in the current thread).
setName
public final void setName(
String name
)
Changes the name of this thread to be equal to the argument
name.
First the checkAccess method of this thread is called
with no arguments. This may result in throwing a
SecurityException.
setPriority
public final void setPriority(
int newPriority
)
Changes the priority of this thread.
First the checkAccess method of this thread is called
with no arguments. This may result in throwing a
SecurityException.
Otherwise, the priority of this thread is set to the smaller of
the specified newPriority and the maximum permitted
priority of the thread's thread group.
start
public synchronized native void start(
)
Causes this thread to begin execution; the Java Virtual Machine
calls the run method of this thread.
The result is that two threads are running concurrently: the
current thread (which returns from the call to the
start method) and the other thread (which executes its
run method).
stop
public final void stop(
)
Forces the thread to stop executing.
If there is a security manager installed, its checkAccess
method is called with this
as its argument. This may result in a
SecurityException being raised (in the current thread).
If this thread is different from the current thread (that is, the current
thread is trying to stop a thread other than itself), the
security manager's checkPermission method (with a
RuntimePermission("stopThread") argument) is called in
addition.
Again, this may result in throwing a
SecurityException (in the current thread).
The thread represented by this thread is forced to stop whatever
it is doing abnormally and to throw a newly created
ThreadDeath object as an exception.
It is permitted to stop a thread that has not yet been started.
If the thread is eventually started, it immediately terminates.
An application should not normally try to catch
ThreadDeath unless it must do some extraordinary
cleanup operation (note that the throwing of
ThreadDeath causes finally clauses of
try statements to be executed before the thread
officially dies). If a catch clause catches a
ThreadDeath object, it is important to rethrow the
object so that the thread actually dies.
The top-level error handler that reacts to otherwise uncaught
exceptions does not print out a message or otherwise notify the
application if the uncaught exception is an instance of
ThreadDeath.
stop
public final synchronized void stop(
Throwable obj
)
Forces the thread to stop executing.
If there is a security manager installed, the checkAccess
method of this thread is called, which may result in a
SecurityException being raised (in the current thread).
If this thread is different from the current thread (that is, the current
thread is trying to stop a thread other than itself) or
obj is not an instance of ThreadDeath, the
security manager's checkPermission method (with the
RuntimePermission("stopThread") argument) is called in
addition.
Again, this may result in throwing a
SecurityException (in the current thread).
If the argument obj is null, a
NullPointerException is thrown (in the current thread).
The thread represented by this thread is forced to complete
whatever it is doing abnormally and to throw the
Throwable object obj as an exception. This
is an unusual action to take; normally, the stop method
that takes no arguments should be used.
It is permitted to stop a thread that has not yet been started.
If the thread is eventually started, it immediately terminates.
suspend
public final void suspend(
)
Suspends this thread.
First, the checkAccess method of this thread is called
with no arguments. This may result in throwing a
SecurityException (in the current thread).
If the thread is alive, it is suspended and makes no further
progress unless and until it is resumed.
toString
public String toString(
)
Returns a string representation of this thread, including the
thread's name, priority, and thread group.