[squeak-dev] problem with threads
Bert Freudenberg
bert at freudenbergs.de
Mon Mar 30 15:28:40 UTC 2009
On 30.03.2009, at 17:13, Damien Cassou wrote:
> On Mon, Mar 30, 2009 at 5:03 PM, Jordi Delgado
> <jdelgado at lsi.upc.edu> wrote:
>> | s p1 p2 |
>> s := SharedQueue new: 20.
>> p1 := [1 to: 10 do: [:i | s nextPut: i. Processor yield.]]
>> newProcess.
>> p2 := [11 to: 20 do: [:i | s nextPut: i. Processor yield.]]
>> newProcess.
>> p1 priority: Processor activePriority - 1.
>> p2 priority: Processor activePriority - 1.
>> p1 resume. p2 resume.
>> s inspect.
>
> Try to rename your block variables i to i1 and i2. You can also try
> sending the message #fixTemps to the blocks.
Right. The compiler rewrites the #to:do: loop into a #whileTrue: loop
and uses the same method-level temp "i" for both loops. This issue
(among others) will be fixed with the "closure compiler".
- Bert -
More information about the Squeak-dev
mailing list
|