From 787c12da0b76cc9b0bfce90229cb26cbf2594426 Mon Sep 17 00:00:00 2001 From: naruse Date: Mon, 23 Jul 2012 19:04:15 +0000 Subject: Synchronize with simple variable assignment. If it uses Queue, Mutex#synchronize may suppress the exception caused by th.raise. The case happens when Ruby switches the thread after it pushes :go into q, in `self.unlock rescue nil`. The exception is rescued the `rescue nil`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_thread.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb index 870e559685..523cad4242 100644 --- a/test/ruby/test_thread.rb +++ b/test/ruby/test_thread.rb @@ -618,23 +618,22 @@ class TestThread < Test::Unit::TestCase def make_control_interrupt_test_thread1 flag r = [] - q = Queue.new + ready_p = false th = Thread.new{ begin Thread.control_interrupt(RuntimeError => flag){ - q << :go begin + ready_p = true sleep 0.5 rescue r << :c1 end } - sleep 0.5 rescue r << :c2 end } - q.pop # wait + Thread.pass until ready_p th.raise begin th.join -- cgit v1.2.3