I want to achieve following kind of scenario using pthreads: There are two kinds of threads in a thread pool. First kind executes (say) fun1 second executes fun2. The main thread starts these two threads (for simplicity assume that there are only two worker threads in the pool each of the above two different kinds). The main thread then waits for one of the threads to finish. The first thread to finish notifies the main thread, the main thread then should notify the other worker thread to quit executing its job. And the cycle goes on.
Now if I wanted to stop a thread from executing its job, which can be like memmove/lock acquire, then I think it's best to just kill/cancel that thread and recreate it. What do you guys think?
Also if I cancel the thread (pthread_cancel) then it seems like I will have to call pthread_join to ensure it's actually canceled and then recreate it. Is that true?
Thanks, Nilesh.