From: Jacek Olszak Date: 2006-01-09T04:54:11+09:00 Subject: Re: Newbie question about threads and gets Jacek Olszak wrote: > Robert Klemme wrote: >> Jacek Olszak wrote: >>> >>> >>> Unfortunelty "gets" block my whole application - the "b" thread waits >>> until user writes something to the stdin. But I want the b thread not >>> wait and run at the same time. >>> >>> Thanks >>> Jacek >> >> I'm not sure what you're up to in the end but I'd start with commenting >> Thread.pass. Ruby normally schedules threads automatically and thus you >> usually don't need Thread.pass. And btw, you can do $stdout.sync=true - >> which removes the necessity of invoking flush. >> >> Ah, and another note: the first thread blocks the whole app until you >> enter >> something simply because it's joined on. The main thread won't exit >> until >> you enter something. >> >> HTH >> >> robert > > First of all... thanks for help. I've set sync to true and remove > Thread.pass. (but as you said these things won't fix the problem). So > I've removed _a.join_ call and now everything works! (but wait a second > - only on my newly installed linux :(, on windows works only with Bill > solution) > I don't know hot it is possible but this code works on windows too : $stdout.sync=true a=Thread.new do 50.times do $stdin.gets puts "=="+$aaa.to_s end end b=Thread.new do 10000000000.times do |i| $aaa=i # Thread.pass - when uncomment this - works on linux only, when comment this - works on windows only :) end end b.join Thanks a lot once again! Jacek -- Posted via http://www.ruby-forum.com/.