ruby thread and gets



[Note: parts of this message were removed to make it a legal post.]

Hi all
I'm trying to run two thread at one time in a program.
And one of them will receive user inputting msgs by gets().
another one will do something else at the same time.
they don't communicate each other.

like this :

thread_a = Thread.new{
loop do
puts "please enter blah blah"
msg = gets
#do something
end
}
thread_a.join
thread_b = Thread.new{
loop do
#do other things maybe puts "im running im running
......"
end

}
thread_b.join

but when thread_a runs gets waiting for user input, whole program will be
paused waiting for this, I mean thread_b will not working.
How can I handle this ?
Do I have to do this by running multi process?

.



Relevant Pages

  • Re: ruby thread and gets
    ... puts "please enter blah blah" ... paused waiting for this, I mean thread_b will not working. ... Thanks Robert. ...
    (comp.lang.ruby)
  • Re: ruby thread and gets
    ... And one of them will receive user inputting msgs by gets. ... puts "please enter blah blah" ... paused waiting for this, I mean thread_b will not working. ...
    (comp.lang.ruby)
  • Re: deaf grandma.
    ... puts "Simon says, ... and check the flag each time to see whether we loop again. ... puts "that was in all caps" ...
    (comp.lang.ruby)
  • Re: (beginner) Substitution - braces and double quotes
    ... the $vars get substituted the moment Tcl reads the string. ... defer this substitution. ... not understand is that, after line 5 (first passage of while loop), ... of puts in my first message), even if at the end the loop ends as ...
    (comp.lang.tcl)
  • [SUMMARY] Word Loop (#149)
    ... cheater is a wonderful label for a programmer to have. ... the first priority is to find a possible loop. ... puts before+letter+looplets.shift ...
    (comp.lang.ruby)