summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-16 06:34:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-16 06:34:47 +0000
commit2c3522c3e403dfdadaaf6095564bde364cc4bddf (patch)
tree52e7ff4e4a81ac00f4163171cd2312b97da442e1 /test
parente9bb3b9d305b438c89701a36e34de5fb1ee98991 (diff)
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
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_thread.rb8
1 files 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