Hi George,
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?
Ron Teitelbaum
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.
2222222212121111111 2222222121212111111 22222222221111111111 2212121212121212121 2222222222111111111 2222222222111111111 2222121212121212111 22222222221111111111 22222222221111111111 2212121212121212121 ...
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?
Thanks,
George
P.S. Execuse me my poor english, please. _______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners