| 18 | |
| 19 | |
| 20 | void Thread::start(void) |
| 21 | { |
| 22 | if(!obj) throw(Error("Thread::start()", "Unexpected NULL pointer")); |
| 23 | |
| 24 | #ifdef _WIN32 |
| 25 | |
| 26 | DWORD tid; |
| 27 | if((handle = CreateThread(NULL, 0, threadFunc, obj, 0, &tid)) == NULL) |
| 28 | throw(W32Error("Thread::start()")); |
| 29 | |
| 30 | #else |
| 31 | |
| 32 | int err = 0; |
| 33 | if((err = pthread_create(&handle, NULL, threadFunc, obj)) != 0) |
| 34 | throw(Error("Thread::start()", strerror(err == -1 ? errno : err))); |
| 35 | |
| 36 | #endif |
| 37 | } |
| 38 | |
| 39 | |
| 40 | void Thread::stop(void) |