[Newbies] Re: Semaphore problems
kutsuya at gmail.com
Sun Sep 30 00:28:49 UTC 2007
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.
b1 a1 a2 b2
It's kind of strange why this only seems to bite me. :/
Thanks for the help,
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Beginners