How do you run several pthreads, in C, and detect the first to terminate?
I'm thinking there has got to be an interface similar to select() for sockets to do this with threads.
Thanks, Chenz
How do you run several pthreads, in C, and detect the first to terminate?
I'm thinking there has got to be an interface similar to select() for sockets to do this with threads.
Thanks, Chenz
Use a shared message queue (with a mutex/condition) and have each thread post a message when they are finished.
Have a shared variable protected by a mutex, have the thread write its pthread id
In all cases, you can have a condition
in order to wait
effectively without too much polling.