Re: How to wait for multiple threads simultaneously?



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
.



Relevant Pages

  • Re: Network slow after Domain join
    ... No more waiting 10minutes to log into the domain. ... If i uninstall "client for microsoft network" it also boots fast.. ...
    (microsoft.public.windowsxp.network_web)
  • Re: Cant start BITS - Cant run Windows Update
    ... Whilst you're waiting for a response, ... > from both Microsoft and Dell but have been unable to resolve this matter. ... > then turned my case over to level 2 tech support. ...
    (microsoft.public.windowsupdate)
  • Re: select() in a thread
    ... > force a file descriptor to become active (short of sending ... "Tickling" selector a descriptor it's waiting on smacks ... > feed that same thread some outbound data. ... How about using a pipe? ...
    (comp.unix.programmer)
  • Re: Still need an MVP answer for XP Pro file share
    ... Microsoft refers us to this site and we depend on the ... time for posts ... >complaining that you are still waiting is just getting ...
    (microsoft.public.windowsxp.general)
  • Re: Polish Spell Check
    ... Poor Microsoft, that word (Translated into colloquial Polish means ... twice as much as Linux or Widoze machine), waiting for Microsoft to ... MVPs are not MS employees - Les MVP ne travaillent pas pour MS ...
    (microsoft.public.mac.office.word)