You need to learn about threads.
All programs have at least a thread, but most console applications only have one. This way, a program can only do one thing at a time.
Imagine a program with two threads as two programs that work together towards a goal.
You can create one thread that does the computing, one that prints all the output and one that keeps reading data from the keyboard. This will create a program that can write and read at the same time.
Also, keep in mind that you need to use a multi-processor machine in order for threads to offer true parallelism to your program.
Here is a ruby example that can read and write data from/to the console at the same time:
a = Thread.new do
while true do
puts "Hi There!"
sleep(1)
end
end
b = Thread.new do
while true do
puts gets.strip+"!"
end
end
a.join
b.join