[Newbies] BlockClosure>>fork problem
Ron at USMedRec.com
Mon Feb 19 22:46:37 UTC 2007
I'm not sure what you expect to happen. The code you are running basically
says go off on your own and do something. A fork creates a different thread
that processes instructions on its own, but the two processes are not
coordinated the scheduler just gives them time when it can. Notice though
that the Transcript cr. runs first which shows you that the two forked lines
above went off on their own.
VW may give the illusion that the processes are coordinated but they may
just have a better, more consistent scheduler. Bottom line is you should
not count on threads to process in any coordinated way.
Does that help?
> From: George Herolyants
> Sent: Monday, February 19, 2007 4:46 PM
> Hi all,
> I'm new to Smalltalk and Squeak and I have a question.
> I tried some examples from chapter Processes from "Smalltalk by Example"
> book. I executed the following code several times but the output was
> quite different as I suppose and differed from time to time.
> Furthermore evaluation went a bit slowly.
> [10 timesRepeat: [Transcript show: '2']] fork.
> [10 timesRepeat: [Transcript show: '1']] fork.
> Transcript cr.
> In VisualWorks the same example works right. As described in the book.
> I use Squeak 3.9 7067.
> Is this a bug or i do something wrong?
> P.S. Execuse me my poor english, please.
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
More information about the Beginners