Hey, cool, thanks a lot!
El 02/11/2012, a las 19:40, Bert Freudenberg escribió: > On 2012-11-02, at 19:24, Sebastian Nozzi <[email protected]> wrote: > >> Is it possible to have one thread wait for 2 other threads to finish? Would >> it also be solved with Semaphores like this? >> >> s1 := Semaphore forMutualExclusion. >> s2 := Semaphore forMutualExclusion. >> [ s1 wait. do stuff .... s1 signal] fork. >> [ s2 wait. do stuff ..... s2 signal ] fork. >> >> s1 wait. >> s2 wait. >> "Here we are sure the two other processes finished, kind of..." >> >> Or is there a more "friendly" way? :-) > > Looks okay to me. But you could make it a bit simpler: > > s1 := Semaphore new. > s2 := Semaphore new. > [ do stuff .... s1 signal] fork. > [ do stuff ..... s2 signal] fork. > s1 wait. > s2 wait. > > Or even: > > s1 := Semaphore new. > [ do stuff .... s1 signal] fork. > [ do stuff ..... s1 signal] fork. > s1 wait; wait. > > - Bert - _______________________________________________ Beginners mailing list [email protected] http://lists.squeakfoundation.org/mailman/listinfo/beginners
