summaryrefslogtreecommitdiff
path: root/test/monitor
diff options
context:
space:
mode:
Diffstat (limited to 'test/monitor')
-rw-r--r--test/monitor/test_monitor.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/monitor/test_monitor.rb b/test/monitor/test_monitor.rb
index 451e26cc7a..088bf28a37 100644
--- a/test/monitor/test_monitor.rb
+++ b/test/monitor/test_monitor.rb
@@ -33,6 +33,22 @@ class TestMonitor < Test::Unit::TestCase
assert_equal((1..10).to_a, ary)
end
+ def test_enter_second_after_killed_thread
+ th = Thread.start {
+ @monitor.enter
+ Thread.current.kill
+ @monitor.exit
+ }
+ th.join
+ @monitor.enter
+ @monitor.exit
+ th2 = Thread.start {
+ @monitor.enter
+ @monitor.exit
+ }
+ assert_join_threads([th, th2])
+ end
+
def test_synchronize
ary = []
queue = Queue.new
@@ -111,6 +127,22 @@ class TestMonitor < Test::Unit::TestCase
assert_join_threads([th, th2])
end
+ def test_try_enter_second_after_killed_thread
+ th = Thread.start {
+ assert_equal(true, @monitor.try_enter)
+ Thread.current.kill
+ @monitor.exit
+ }
+ th.join
+ assert_equal(true, @monitor.try_enter)
+ @monitor.exit
+ th2 = Thread.start {
+ assert_equal(true, @monitor.try_enter)
+ @monitor.exit
+ }
+ assert_join_threads([th, th2])
+ end
+
def test_cond
cond = @monitor.new_cond