Re: How to wait for multiple threads simultaneously?
- From: David Schwartz <davids@xxxxxxxxxxxxx>
- Date: Tue, 12 Feb 2008 11:28:23 -0800 (PST)
On Feb 11, 6:21 pm, chj...@xxxxxxxxx wrote:
I'd like to ask whether Linux provides an effective way to wait for
multiple thread's end. Using pthread_join, I can only wait for one
thread at a time. Microsoft provides WaitForMultipleObject for doing
this , how about glibc or POSIX?
Just wait for them one at a time, in any order.
An even harder question, how can I wait for one thread's end and one
file descriptor(e.g STDIN_FILENO) to be readable simultaneously? -- If
either one of the two conditions becomes fulfilled, the other one must
quit its waiting status immediately as if no wait operation was
carried
out.
Have one thread wait for the thread's end and one thread wait for the
file descriptor. Have those threads signal a condition variable if the
event they are waiting for occurs. You can then spin on that condition
variable.
There are many other ways, but the short answer is "code what you
need".
DS
.
- Follow-Ups:
- Re: How to wait for multiple threads simultaneously?
- From: Rainer Weikusat
- Re: How to wait for multiple threads simultaneously?
- References:
- How to wait for multiple threads simultaneously?
- From: chjfth
- How to wait for multiple threads simultaneously?
- Prev by Date: Re: How to wait for multiple threads simultaneously?
- Next by Date: I can't find gdk source tarballs and am serious pissed
- Previous by thread: Re: How to wait for multiple threads simultaneously?
- Next by thread: Re: How to wait for multiple threads simultaneously?
- Index(es):
Relevant Pages
|