java.lang
Class Thread
java.lang.Object
|
+--java.lang.Thread
- public abstract class Thread
- extends Object
A thread of execution (or task). Now handles priorities, daemon threads
and interruptions.
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. |
MIN_PRIORITY
public static final int MIN_PRIORITY
- The minimum priority that a thread can have. The value is 1.
NORM_PRIORITY
public static final int NORM_PRIORITY
- The priority that is assigned to the primordial thread. The value is 5.
MAX_PRIORITY
public static final int MAX_PRIORITY
- The maximum priority that a thread can have. The value is 10.
Thread
public Thread()
Thread
public Thread(String name)
isAlive
public final boolean isAlive()
run
public abstract void run()
start
public final void start()
yield
public static void yield()
sleep
public static void sleep(long aMilliseconds)
throws InterruptedException
currentThread
public static Thread currentThread()
getPriority
public final int getPriority()
setPriority
public final void setPriority(int priority)
- Set the priority of this thread. Higher number have higher priority.
The scheduler will always run the highest priority thread in preference
to any others. If more than one thread of that priority exists the
scheduler will time-slice them. In order for lower priority threas
to run a higher priority thread must cease to be runnable. i.e. it
must exit, sleep or wait on a monitor. It is not sufficient to just
yield.
Threads inherit the priority of their parent. The primordial thread
has priority NORM_PRIORITY.
- Parameters:
priority
- must be between MIN_PRIORITY and MAX_PRIORITY.
interrupt
public void interrupt()
- Set the interrupted flag. If we are asleep we will wake up
and an InterruptedException will be thrown.
interrupted
public static boolean interrupted()
isInterrupted
public final boolean isInterrupted()
isDaemon
public final boolean isDaemon()
- Set the daemon flag. If a thread is a daemon thread its existence will
not prevent a JVM from exiting.
setDaemon
public final void setDaemon(boolean on)
join
public final void join()
throws InterruptedException
- Join not yet implemented
join
public final void join(long timeout)
throws InterruptedException