From 2c3522c3e403dfdadaaf6095564bde364cc4bddf Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 16 Jan 2014 06:34:47 +0000 Subject: [PATCH] test_thread.rb: stop at once * test/ruby/test_thread.rb (test_priority): stop both threads at once by a flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_thread.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index fedab8791e..6622d48654 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -127,17 +127,21 @@ class TestThread < Test::Unit::TestCase def test_priority c1 = c2 = 0 - t1 = Thread.new { loop { c1 += 1 } } + run = true + t1 = Thread.new { c1 += 1 while run } t1.priority = 3 - t2 = Thread.new { loop { c2 += 1 } } + t2 = Thread.new { c2 += 1 while run } t2.priority = -3 assert_equal(3, t1.priority) assert_equal(-3, t2.priority) sleep 0.5 5.times do + assert_not_predicate(t1, :stop?) + assert_not_predicate(t2, :stop?) break if c1 > c2 sleep 0.1 end + run = false t1.kill t2.kill assert_operator(c1, :>, c2, "[ruby-dev:33124]") # not guaranteed