From: Ross Bamford Date: 2006-11-10T03:50:20+09:00 Subject: Re: Ruby and threads: a VTK example On Thu, 09 Nov 2006 18:21:38 -0000, Aureliano Buendia wrote: > Ross, > > Forget about vtk, put it this way. Save this in a script and run it by > irb: > > i = 1 > while 1 > puts i > end > > It doesn't allow you to add any more command lines unless the > never-ending while-loop is over. True. > Wrapping this in a thread does not help it too: > > Thread.new{ > i = 1 > while 1 > puts i > end > } > Apart from the fact that the output makes it difficult to type, that works fine for me, with one small change - you need to declare 'i' before you start the thread - otherwise, it'll be local to the block you run in the thread. So try (rubified a bit): i = 1 Thread.new { loop { puts i } } You'll get lots of '1's printed out. If you just jump in and type 'i = 2' and hit return, the '1's become '2's. Does that not work for you? -- Ross Bamford - rosco@roscopeco.remove.co.uk