From: Wink Saville Date: 2005-10-20T12:57:22+09:00 Subject: Re: wxruby unfriendly to Ruby threads? Guillaume Marcais wrote: >I have a GUI application with a bunch of threads proxying network >information around. But the network communication seems very slow if not >stopped. To make sure, I added a "keep alive" thread: > >Thread.new do > loop do > puts("Keep alive #{Time.now}") > sleep 1 > end >end > >This thread hangs after a little while and stop outputting anything. If >I move the mouse over the window, a bunch of lines are printed by the >keep alive thread, all at once with the same time, and then it hangs >until the next GUI event. > >Is this a known problem? Or am I completely misguided? > >Guillaume. > > > > On my system running windows I need to redefine puts as below to flush the output: def puts(s) STDOUT.puts(s) STDOUT.flush end As for the threads, how many is a bunch? I've been looking at the scheduler and it looks to me that each time a thread is scheduled the entire list of threads is looped through at least twice and as many as 5 times. I'm looking into other possible algorithms, but I'm a newbie so not sure what progress I'll make. But it looks to be an interesting problem and I believe it is solvable. Cheers, Wink