|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
public class Thread
A thread of execution (or task). Now handles priorities, daemon threads and interruptions.
Nested Class Summary | |
---|---|
static interface |
Thread.UncaughtExceptionHandler
|
Field Summary | |
---|---|
static int |
MAX_PRIORITY
The maximum priority that a thread can have. |
static int |
MIN_PRIORITY
The minimum priority that a thread can have. |
static int |
NORM_PRIORITY
The priority that is assigned to the primordial thread. |
Constructor Summary | |
---|---|
Thread()
|
|
Thread(Runnable target)
|
|
Thread(Runnable target,
String name)
|
|
Thread(String name)
|
Method Summary | |
---|---|
static Thread |
currentThread()
|
static Thread.UncaughtExceptionHandler |
getDefaultUncaughtExceptionHandler()
returns the current default exception handler if set, or null if none is set. |
String |
getName()
Returns the string name of this thread. |
int |
getPriority()
|
Thread.UncaughtExceptionHandler |
getUncaughtExceptionHandler()
returns the current uncaught exception handler for this thread, if one has has been set or null if none is set. |
void |
interrupt()
Set the interrupted flag. |
static boolean |
interrupted()
Tests the interrupted state of the current thread. |
boolean |
isAlive()
|
boolean |
isDaemon()
Set the daemon flag. |
boolean |
isInterrupted()
Tests to see if the current thread has been interrupted but leaves the interrupted state unchanged. |
void |
join()
Waits for this thread to die. |
void |
join(long timeout)
Waits for up to timeout mS for this thread to die. |
void |
run()
When an object implementing interface Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread. |
void |
setDaemon(boolean on)
Sets the state of the threads daemon flag. |
static void |
setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
Set the default exception handler. |
void |
setName(String name)
Sets the string name associated with this thread. |
void |
setPriority(int priority)
Set the priority of this thread. |
void |
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
Sets the uncaught exception handler for this thread. |
static void |
sleep(long aMilliseconds)
|
void |
start()
|
static void |
yield()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
public static final int MAX_PRIORITY
Constructor Detail |
---|
public Thread()
public Thread(String name)
public Thread(Runnable target)
public Thread(Runnable target, String name)
Method Detail |
---|
public final boolean isAlive()
public void run()
Runnable
Runnable
is used
to create a thread, starting the thread causes the object's
run
method to be called in that separately executing
thread.
run
in interface Runnable
public final void start()
public static void yield()
public static void sleep(long aMilliseconds) throws InterruptedException
InterruptedException
public static Thread currentThread()
public final int getPriority()
public String getName()
public void setName(String name)
name
- The new name of the thread.public final void setPriority(int priority)
Threads inherit the priority of their parent. The primordial thread has priority NORM_PRIORITY.
priority
- must be between MIN_PRIORITY and MAX_PRIORITY.public void interrupt()
public static boolean interrupted()
public final boolean isInterrupted()
public final boolean isDaemon()
public final void setDaemon(boolean on)
on
- the new state of the daemon flagpublic final void join() throws InterruptedException
InterruptedException
public final void join(long timeout) throws InterruptedException
timeout
- The period in ms to wait for this thread to die
InterruptedException
public static void setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
handler
- The new exception handlerpublic static Thread.UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()
public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
handler
- The new handlerpublic Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |