[Newbies] Re: Semaphore problems

Jason Shoemaker kutsuya at gmail.com
Sun Sep 30 00:28:49 UTC 2007


Hello,

After Matthew pointed out that Transcript>>show: isn't tread-safe, I changed
it to Transcript>>nextPutAll:

The script still wasn't give the expected output. So after playing around a
bit, I discovered if I waited just a bit before flushing it would then
work.  It feels like a hack though.

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

[Transcript cr; nextPutAll: 'b1'. semB signal. semA wait.
        Transcript cr; nextPutAll: 'b2'. ] fork.
[Transcript cr; nextPutAll: 'a1'. semA signal. semB wait.
        Transcript cr; nextPutAll: 'a2'.] fork.
(Delay forMilliseconds: 1) wait.
Transcript flush

Results:

b1 a1 a2 b2

It's kind of strange why this only seems to bite me. :/

Thanks for the help,
  JTS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20070930/cc13b9fa/attachment.htm


More information about the Beginners mailing list