Updated RubySpec source to 55122684.
[rbx.git] / spec / frozen / 1.8 / core / thread / shared / exit.rb
blob84872f577e47110be2c46f0c62fd8a8b4303c7a2
1 shared :thread_exit do |cmd|
2   describe "Thread\##{cmd}" do
4     # This case occurred in JRuby where native threads are used to provide
5     # the same behavior as MRI green threads. Key to this issue was the fact
6     # that the thread which called #exit in its block was also being explicitly
7     # sent #join from outside the thread. The 100.times provides a certain
8     # probability that the deadlock will occur. It was sufficient to reliably
9     # reproduce the deadlock in JRuby.
10     it "does not deadlock when called from within the thread while being joined from without" do
11       100.times do
12         t = Thread.new { Thread.stop; Thread.current.send(cmd) }
13         Thread.pass until t.status == "sleep"
14         t.wakeup.should == t
15         t.join.should == t
16       end
17     end
18   end
19 end