#include <threads.h>
Public Member Functions | |
Thread () | |
Create a new thread. | |
Thread (Runnable &r) | |
Create a new thread which will execute the given Runnable. | |
virtual | ~Thread () |
Destroy thread. | |
virtual void | run () |
If this thread was constructed using a separate Runnable run object, then that Runnable object's run method is called; otherwise, this method does nothing and returns. | |
Runnable & | get_runnable () |
Get the Runnable object used for thread execution. | |
void | join () |
Waits for this thread to die. | |
void | start () |
Causes this thread to begin execution; the system calls the run method of this thread. | |
void | set_stack_size (long s) |
Before calling the start method this method can be used to change the stack size of the thread. | |
boolean | is_alive () |
Check whether thread is alive. | |
Thread * | clone () |
Clone this thread. | |
Static Public Member Functions | |
static void | sleep (long millis) |
Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds. | |
static void | sleep (long millis, int nanos) |
Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds. | |
Friends | |
class | Synchronized |
void * | thread_starter (void *) |
There are two ways to create a new thread of execution. One is to declare a class to be a subclass of Thread. This subclass should override the run method of class Thread. An instance of the subclass can then be allocated and started.
The other way to create a thread is to declare a class that implements the Runnable interface. That class then implements the run method. An instance of the class can then be allocated, passed as an argument when creating Thread, and started.
Thread::Thread | ( | ) |
Create a new thread.
Thread::Thread | ( | Runnable & | r | ) |
virtual Thread::~Thread | ( | ) | [virtual] |
Destroy thread.
If thread is running or has been finished but not joined yet, then join it.
static void Thread::sleep | ( | long | millis | ) | [static] |
Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds.
millis | number of milliseconds to sleep. |
static void Thread::sleep | ( | long | millis, | |
int | nanos | |||
) | [static] |
Causes the currently executing thread to sleep (cease execution) for the specified number of milliseconds plus the specified number of nanoseconds.
millis | the length of time to sleep in milliseconds. | |
nanos | 0-999999 additional nanoseconds to sleep. |
virtual void Thread::run | ( | ) | [virtual] |
Runnable& Thread::get_runnable | ( | ) |
void Thread::join | ( | ) |
Waits for this thread to die.
void Thread::start | ( | ) |
Causes this thread to begin execution; the system calls the run method of this thread.
void Thread::set_stack_size | ( | long | s | ) | [inline] |
Before calling the start method this method can be used to change the stack size of the thread.
stackSize | the thread's stack size in bytes. |
boolean Thread::is_alive | ( | ) | [inline] |
Check whether thread is alive.
Thread* Thread::clone | ( | ) | [inline] |
Clone this thread.
This method must not be called on running threads.
friend class Synchronized [friend] |
void* thread_starter | ( | void * | ) | [friend] |