Original Post
I was thinking in develop a class that handle the thread stuff for me, so my app will work something like in Java. I think this is a good idea. Searched in goole and found a exemple from codeproject.com, but only work in win32. How to get to work in my linux system?
// define the interface
struct IRunnable {
virtual void run() = 0;
};
// define the thread class
class Thread {
public:
Thread(IRunnable *ptr) {
_threadObj = ptr;
}
void start() {
// use the Win32 API here
DWORD threadID;
::CreateThread(0, 0, threadProc, _threadObj, 0, &threadID);
}
protected:
// Win32 compatible thread parameter and procedure
IRunnable *_threadObj;
static unsigned long __stdcall threadProc(void* ptr) {
((IRunnable*)ptr)->run();
return 0;
}
};