J
Jacek Olszak
Hi everyone...
I've a simple question - how can I write an application with two
threads, where first thread reads the user input. I want both threads to
run SIMULTANEOUSLY.
So .. here is my code:
a=Thread.new do
$stdin.gets
end
b=Thread.new do
5.times do
print "b"
$stdout.flush
Thread.pass
end
end
a.join
b.join
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've a simple question - how can I write an application with two
threads, where first thread reads the user input. I want both threads to
run SIMULTANEOUSLY.
So .. here is my code:
a=Thread.new do
$stdin.gets
end
b=Thread.new do
5.times do
print "b"
$stdout.flush
Thread.pass
end
end
a.join
b.join
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