|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
public class Thread
Class to represent and manage a thread of execution.
Field Summary | |
---|---|
static int |
MAX_PRIORITY
Highest thread priority. |
static int |
MIN_PRIORITY
Lowest thread priority. |
static int |
NORM_PRIORITY
Normal thread priority. |
Constructor Summary | |
---|---|
Thread()
Constructs a new thread with a default name and no Runnable. |
|
Thread(Runnable runnable)
Constructs a new Thread object with a default name. |
|
Thread(Runnable runnable,
String name)
Constructs a new Thread object. |
|
Thread(String name)
Constructs a new Thread object with a name but no Runnable. |
Method Summary | |
---|---|
static int |
activeCount()
Returns the count of active threads. |
static Thread |
currentThread()
Returns the Thread object for the current thread. |
static void |
dumpStack()
Dumps a stack trace for the current state of this thread. |
String |
getName()
Gets the name of this thread. |
int |
getPriority()
Gets the priority of this thread. |
void |
interrupt()
Interrupts this thread. |
static boolean |
interrupted()
Indicates if the current thread has been interrupted. |
boolean |
isAlive()
Returns if this thread is currently alive (hasn't terminated). |
boolean |
isDaemon()
Returns true if this thread is a daemon thread. |
boolean |
isInterrupted()
Indicates if this thread has been interrupted. |
void |
join()
Suspends the current thread until this thread terminates or the current thread is interrupted. |
void |
join(long milliseconds)
Suspends the current thread until this thread terminates or the specified time expires or the current thread is interrupted. |
void |
run()
Runs the run method in this thread's Runnable object. |
void |
setDaemon(boolean daemon)
Sets the daemon state of this thread. |
void |
setName(String name)
Sets the name of this thread. |
void |
setPriority(int priority)
Sets the priority of this thread. |
static void |
sleep(long milliseconds)
Puts the current thread to sleep for the number of milliseconds specified or until the thread is interrupted. |
void |
start()
Makes this thread runnable and queues it to run. |
String |
toString()
Returns a string represetation of this thread. |
static void |
yield()
Causes the current Thread to yield allowing other threads of the same priority to run. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait |
Field Detail |
---|
public static final int MAX_PRIORITY
public static final int MIN_PRIORITY
public static final int NORM_PRIORITY
Constructor Detail |
---|
public Thread()
public Thread(Runnable runnable)
runnable
- object whose run method is to be called when the thread startspublic Thread(Runnable runnable, String name)
runnable
- object whose run method is to be called when the thread startsname
- thread namepublic Thread(String name)
name
- thread nameMethod Detail |
---|
public static int activeCount()
public static Thread currentThread()
public static void dumpStack()
public final String getName()
public final int getPriority()
public void interrupt()
public static boolean interrupted()
public final boolean isAlive()
public boolean isDaemon()
public boolean isInterrupted()
public final void join() throws InterruptedException
InterruptedException
public final void join(long milliseconds) throws InterruptedException
milliseconds
- maximum time to wait
InterruptedException
public void run()
Subclasses may override this method in lieu of using a Runnable object.
run
in interface Runnable
public void setDaemon(boolean daemon)
An application will exit when the last non-daemon thread terminates.
daemon
- true if the thread is a daemon thread, otherwise falsepublic final void setName(String name)
name
- new namepublic final void setPriority(int priority)
priority
- new prioritypublic static void sleep(long milliseconds) throws InterruptedException
milliseconds
- milliseconds to sleep
InterruptedException
public void start()
public String toString()
toString
in class Object
public static void yield()
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |