[Newbies] Acquiring lock, releasing in callback
sebnozzi at gmail.com
Fri Nov 2 18:24:00 UTC 2012
Didn't know it was so simple... I was kind of intimidated by "wait". Thought, well, that it suspended the thread no matter what.
Another question, out of curiosity:
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.
"Here we are sure the two other processes finished, kind of..."
Or is there a more "friendly" way? :-)
> You could use a Semaphore directly:
> semaphore := Semaphore forMutualExclusion.
> and then
> semaphore wait "acquire lock"
> semaphore signal "release lock"
>> I am aware or Monitor/Mutex critical:, but I am not sure I can use it in my case.
> Semaphore>>critical: simply does a wait and signal like above. But it ensures that if something goes wrong the semaphore is still signaled, so it's more easy to use.
> - Bert -
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Beginners