Click to See Complete Forum and Search --> : How to create a thread is suspended state using pthreads


shim
September 20th, 2005, 08:08 AM
Hi all,

I just want to know how to create a thread in suspended state using pthreads and after creation how (which api) to kickstart that thread?

Regards,

Siddhartha
September 20th, 2005, 06:07 PM
thr_suspend (..) and thr_continue (...) (http://docs.sun.com/app/docs/doc/806-6867/6jfpgdcoh?a=view), come closest to what you asked for, perhaps.
(Note that it seems POSIX does not support suspend and continue.)

In general instead of suspending a running thread and continuing it later - it is a good practise to make it stop by waiting on a synchronization object (like mutex or semaphore, etc) - one that is later released.

This way one has accurate control on the state in which the thread was stopped, and the state in which it continues execution.