[Newbies] Simple semaphore to synchronize instances of different classes

Chris Cunningham cunningham.cb at gmail.com
Wed Aug 15 23:42:33 UTC 2012

On Wed, Aug 15, 2012 at 1:11 PM, Chris Cunnington
<smalltalktelevision at gmail.com> wrote:
> On 12-08-15 3:12 PM, patrick dudjalija wrote:
>> |ts sem|
>> sem:=Semaphore new.
>> [ts:= TestSynchro new.
>> ts semaphore:sem.
>> ts openInWorld.
>> ts start.] fork.
>> sem wait.
>> Transcript cr; show:'Hello world !';cr.
> Well, I can observer a few things. The first is that running this code in a
> Workspace the tem vars are unnecessary. (ie. |ts sem|). The second thing is
> that if I execute the code down to "fork" it runs fine. A blue square
> appears in the corner and it counts steps one to nine in the Transcript.
> It's only when you add "sem wait" that it freezes. I had to use Command+. on
> my Mac to unfreeze it. And I'm not convinced this is a bug. Remember, I
> don't think there is a Morph anywhere that uses Semaphore in #step. I have a
> feeling this is not a bug and that it's doing exactly what it's supposed to.
> You have created a Morph and now you've stopped it with #wait. I bet that's
> locking up the entire World, so it appears to freeze. That's my guess.
> HTH,
> Chris

So, if you'd still like to do it this way, if you place your entire
script from the workspace into a [] fork, it should then work (since
it will no longer block the UI process).

More information about the Beginners mailing list