How to create our own thread class using pthread

Hi all,

I want to create a generic thread class in UNIX using pthread.h. But pthread is accepting only "C" functions. But i want to call the C++ functions also. Also my thread class should have all the functions like start(), stop() and resume()
It should be something like this ...

mythread.hpp
~~~~~~~~~~~~~~
class mythread
{

start()
stop()
resume()
mythread()
.....
}


mythread* m = new mythread(objectname for some other class, function name to call for that class);
m->start(); // start executing the the function for that object
etc..

mythread.cpp: //needs the implemetation for those functions.

when i create a new object, a new thread should get created n if i give start, it has to start a particular class function.


Can any one help in providing some good link for this or some idea on how to create this type of classes?



thanks in advance...
you can look at the implementation of boost threads or ace threads..
you dont have to see the whole code.. just the headers will give you a good idea as to how are you going to implement your thread class.

links:

http://www.boost.org/
http://www.boost.org/doc/libs/1_38_0/doc/html/thread.html
http://www.cs.wustl.edu/~schmidt/ACE.html
Topic archived. No new replies allowed.