我使用Pharo编码Smalltalk。我的代码:Smalltalk - 每2秒打印一次东西
|i delay|
i := 0.
[i < 5] whileTrue: [
[
delay := Delay forSeconds: 2.
delay wait.
Transcript show: '2 seconds are up'.
Transcript cr.
] fork.
i := i + 1.
]
它打印出所有的“2秒之后”一次,而不是每2秒时:
2 seconds are up
2 seconds are up
2 seconds are up
2 seconds are up
2 seconds are up
请,谁能告诉我如何打印的东西,每次2秒在Smalltalk?
没错。谢谢! – cawecoy