I am experimenting with multithreading in ruby. I ran this piece of code that runs 3 threads concurrently (ruby threads.rb
in my terminal):
arr = []
arr.push(Thread.new do
1000000.times do |i|
puts "thread 1"
end
end)
arr.push(Thread.new do
1000000.times do |i|
puts "thread 2"
end
end)
arr.push(Thread.new do
1000000.times do |i|
puts "thread 3"
end
end)
arr.each {|t| t.join}
I am now running htop
in tree view in my terminal to see if I can actually see the 3 different threads :
I think the process threads.rb is the line right under the highlighted one, but I cant see my three launched threads as branches of the threads.rb process.. Do ruby threads have nothing to do with threads and processes displayed with htop ? Is there a way to visualize the different ruby threads running inside my threads.rb process.