[ pthread cry for help ... ]
1) buy a good book on programming with threads. i happen to like
"Programming with Threads" by Kleiman, Shah & Smaalders, but there
are others. You'll need it.
2) general method for using C++ objects when starting threads:
class Foo {
public:
static void *function_called_by_thread (void *arg) {
((Foo *) arg)->actual_function_for_thread_to_run ();
}
private:
void *actual_function_for_thread_to_run ();
};
pthread_t thread_id;
Foo *myfoo;
if (pthread_create (&thread_id, 0,
Foo::function_called_by_thread, myfoo) != 0) {
... error: cannot create thread ...
}
At this point, there is a new thread executing
Foo::function_called_by_thread(), which in turn will call
Foo::actual_function_for_thread_to_run().
Hope this helps.
--p