Modifier and Type | Class and Description |
---|---|
static interface |
Thread.UncaughtExceptionHandler |
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
Thread() |
Thread(Runnable target) |
Thread(Runnable target,
String name) |
Thread(String name) |
Modifier and Type | Method and Description |
---|---|
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() |
public static final int MAX_PRIORITY
public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
public Thread()
public Thread(Runnable target)
public Thread(String name)
public static Thread currentThread()
public static Thread.UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()
public String getName()
public final int getPriority()
public Thread.UncaughtExceptionHandler getUncaughtExceptionHandler()
public void interrupt()
public static boolean interrupted()
public final boolean isAlive()
public final boolean isDaemon()
public final boolean isInterrupted()
public 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 dieInterruptedException
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.public final void setDaemon(boolean on)
on
- the new state of the daemon flagpublic static void setDefaultUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
handler
- The new exception handlerpublic 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 setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler)
handler
- The new handlerpublic static void sleep(long aMilliseconds) throws InterruptedException
InterruptedException
public final void start()
public static void yield()