Thread Priority : priority « Threads « Ruby






Thread Priority




$slow = 0
$fast = 0
(Thread.new { loop { $slow += 1 } }).priority = -2
(Thread.new { loop { $fast += 1 } }).priority = -1
sleep 1
Thread.critical = true
puts "The slow thread counted to #{$slow}"
puts "The fast thread counted to #{$fast}"



# The slow thread counted to 11675
# The fast thread counted to 629474

 








Related examples in the same category

1.What is your priority