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