cede control from a thread : Thread.pass « Threads « Ruby






cede control from a thread


2.times { Thread.new { 10.times { |i| print i; $stdout.flush; Thread.pass } } }
Thread.list.each { |thread| thread.join unless thread == Thread.main }

 

Related examples in the same category