次のコードは、改行を入れずにメッセージをスローします。
threads = []
counter = 1000
counter.times do
threads << Thread.new do
puts "This is a line."
sleep 1
end
end
threads.each {|t| t.join}
結果は
This is a line. This is a line
This is a line.
This is a line.
and so on...
結果行をよりきちんとした方法で印刷する方法はありますか?