|
OpenTop 1.5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||||
#include "ot/base/Runnable.h"

To execute a Runnable class's run() method, create a new Thread instance passing a pointer to the Runnable object as a parameter.
Here's a complete, but trivial, example multi-threaded application that doesn't subclass the Thread class - it derives from Runnable instead.
#include "ot/base/SystemMonitor.h"
#include "ot/base/Thread.h"
#include <iostream>
using namespace std;
using namespace ot;
class HelloSayer : public Runnable
{
public:
virtual void run()
{
cout << "Hello World!" << endl;
}
};
int main()
{
SystemMonitor monitor; // ensures correct termination processing
RefPtr<Thread> rpThread = new Thread(new HelloSayer);
rpThread->start();
return 0;
}
| Method Summary | |
virtual void |
run()=0Called by a Thread's start-up function when it has been initiated. |
| Methods inherited from class ot::ManagedObject |
addRef(), getRefCount(), onFinalRelease(), operator=(const ManagedObject&), release() |
| Method Detail |
virtual void run()=0
|
OpenTop 1.5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||||