Project

General

Profile

Backport #1471 ยป mutual_join_bug.rb

Test script. - JohnCarter (John Carter), 05/15/2009 05:19 PM

 
1
require 'thread'
2

    
3
m = Mutex.new
4
m.lock
5
wt2 = Thread.new do
6
   m.lock
7
   sleep 2
8
   m.unlock
9
end
10

    
11
# Ensure wt2 is waiting on m
12
sleep 0.1
13

    
14
wt1 = Thread.new do 
15
   m.lock
16
   m.unlock
17
end
18
# Ensure wt1 is waiting on m
19
sleep 0.1
20

    
21
# Give it to wt2
22

    
23
m.unlock
24

    
25
wt1.join