RoboJDETM v2.0

java.lang
Class Thread

java.lang.Object
  extended by java.lang.Thread
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
AnalogShaftEncoder, BehaviorArbiter, DifferentialDriveNavigator, OdometricLocalizer, ScreenManager

public class Thread
extends Object
implements Runnable

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

MAX_PRIORITY

public static final int MAX_PRIORITY
Highest thread priority.

See Also:
Constant Field Values

MIN_PRIORITY

public static final int MIN_PRIORITY
Lowest thread priority.

See Also:
Constant Field Values

NORM_PRIORITY

public static final int NORM_PRIORITY
Normal thread priority.

See Also:
Constant Field Values
Constructor Detail

Thread

public Thread()
Constructs a new thread with a default name and no Runnable.


Thread

public Thread(Runnable runnable)
Constructs a new Thread object with a default name.

Parameters:
runnable - object whose run method is to be called when the thread starts

Thread

public Thread(Runnable runnable,
              String name)
Constructs a new Thread object.

Parameters:
runnable - object whose run method is to be called when the thread starts
name - thread name

Thread

public Thread(String name)
Constructs a new Thread object with a name but no Runnable.

Parameters:
name - thread name
Method Detail

activeCount

public static int activeCount()
Returns the count of active threads.

Returns:
active thread count

currentThread

public static Thread currentThread()
Returns the Thread object for the current thread.

Returns:
current Thread

dumpStack

public static void dumpStack()
Dumps a stack trace for the current state of this thread.


getName

public final String getName()
Gets the name of this thread.

Returns:
name

getPriority

public final int getPriority()
Gets the priority of this thread.

Returns:
priority

interrupt

public void interrupt()
Interrupts this thread.


interrupted

public static boolean interrupted()
Indicates if the current thread has been interrupted.

Returns:
true if interrupted, otherwise false

isAlive

public final boolean isAlive()
Returns if this thread is currently alive (hasn't terminated).

Returns:
true if alive, otherwise false

isDaemon

public boolean isDaemon()
Returns true if this thread is a daemon thread.

Returns:
true if daemon, otherwise false

isInterrupted

public boolean isInterrupted()
Indicates if this thread has been interrupted.

Returns:
true if interrupted, otherwise false

join

public final void join()
                throws InterruptedException
Suspends the current thread until this thread terminates or the current thread is interrupted.

Throws:
InterruptedException

join

public final void join(long milliseconds)
                throws InterruptedException
Suspends the current thread until this thread terminates or the specified time expires or the current thread is interrupted.

Parameters:
milliseconds - maximum time to wait
Throws:
InterruptedException

run

public void run()
Runs the run method in this thread's Runnable object.

Subclasses may override this method in lieu of using a Runnable object.

Specified by:
run in interface Runnable

setDaemon

public void setDaemon(boolean daemon)
Sets the daemon state of this thread.

An application will exit when the last non-daemon thread terminates.

Parameters:
daemon - true if the thread is a daemon thread, otherwise false

setName

public final void setName(String name)
Sets the name of this thread.

Parameters:
name - new name

setPriority

public final void setPriority(int priority)
Sets the priority of this thread.

Parameters:
priority - new priority

sleep

public static void sleep(long milliseconds)
                  throws InterruptedException
Puts the current thread to sleep for the number of milliseconds specified or until the thread is interrupted.

Parameters:
milliseconds - milliseconds to sleep
Throws:
InterruptedException

start

public void start()
Makes this thread runnable and queues it to run.


toString

public String toString()
Returns a string represetation of this thread.

Overrides:
toString in class Object
Returns:
string

yield

public static void yield()
Causes the current Thread to yield allowing other threads of the same priority to run.


RoboJDETM v2.0

Copyright (c) 2003-2009 RidgeSoft, LLC. All rights reserved.
www.ridgesoft.com