The work done in the new thread may be specified either by passing a Task object to it or by subclassing the Thread class and overwriting the Thread::run function. Note that the creation of a Thread object does not actually generate a new thread. The thread is not created until Thread::start is called.
Public Types | |
| typedef Uint32 | time |
Public Member Functions | |
| ThreadID | getID () const |
| retrieves this thread's id | |
| bool | isRunning () const |
| checks if this thread is running | |
| void | setTask (Task *) |
| sets this thread's task object | |
| void | sleep (time ms) const |
pauses the thread for at least ms milliseconds | |
| void | start () |
| launches the thread | |
| Thread (Task *t=0) | |
| creates a thread with the given task | |
| void | yield () const |
| allows other threads to execute | |
| virtual | ~Thread () |
Static Public Member Functions | |
| static ThreadID | getCurrentID () |
| retrieves the calling thread's id | |
| static bool | isMainThread () |
| checks if the calling thread is the main thread | |
Static Public Attributes | |
| static const ThreadID | INVALID_ID |
Protected Member Functions | |
| virtual void | run () |
| the function executed by this thread | |
Friends | |
| void | waitFor (Thread *) |
| blocks the current thread until the given thread dies | |
|
|
|
|
|
creates a thread with the given task
Note that the thread is not launched until |
|
|
|
|
|
retrieves the calling thread's id
|
|
|
retrieves this thread's id
If this thread is not running, this function returns |
|
|
checks if the calling thread is the main thread The main thread is the thread that the program started with. |
|
|
checks if this thread is running
|
|
|
the function executed by this thread
The default implementation calls the |
|
|
sets this thread's task object
|
|
|
pauses the thread for at least
|
|
|
launches the thread
This function creates the actual system thread, launches it and then returns. It does not wait for the
|
|
|
allows other threads to execute
|
|
|
blocks the current thread until the given thread dies
|
|
|
|
1.4.3