[Newbies] Re: Semaphore problems

Jason Shoemaker kutsuya at gmail.com
Sun Sep 30 01:11:26 UTC 2007

This is probably a safer version.  It works for me.

semA := Semaphore new.
semB := Semaphore new.

thread1 := [Transcript cr; nextPutAll: 'b1'. semB signal. semA wait.
        Transcript cr; nextPutAll: 'b2'. ] fork.
thread2 := [Transcript cr; nextPutAll: 'a1'. semA signal. semB wait.
        Transcript cr; nextPutAll: 'a2'.] fork.

[thread1 isTerminated and: [thread2 isTerminated]] whileFalse:
    [(Delay forMilliseconds: 100) wait].
Transcript flush

Now to move on to another pattern.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20070930/e8ec6109/attachment.htm

More information about the Beginners mailing list