Note: This tutorial assumes that you have completed the previous tutorials: Thread. |
![]() |
Threadable
Description: Threading functionality via inheritance.Keywords: ecl threadable
Tutorial Level: INTERMEDIATE
Next Tutorial: Thread Locks Priorities
The threadable class implements a concept for worker threads that want to retain state information (possibly for use by other parts of the program) in a class. Think of it as a threaded function object rather than a regular c-style threaded function.
Implementation wise, it provides an inheritable interface for your threading class. All the class needs to do is:
inherit the Threadable class.
implement the runnable() method.
call the start() method to begin running in a sepearate thread.
Note that it will not spawn multiple threads - it has a check that ensures it will only execute one thread at any point in time. It is designed to be something more akin to a thread function object rather than a thread factory.