File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -32,8 +32,15 @@ module Concurrent
32
32
describe '#wait without timeout' do
33
33
34
34
it 'should block the thread' do
35
- t = Thread . new { mutex . synchronize { subject . wait ( mutex ) } }
36
- sleep ( 0.1 )
35
+ latch = Concurrent ::CountDownLatch . new
36
+ t = Thread . new do
37
+ mutex . synchronize do
38
+ latch . count_down
39
+ subject . wait ( mutex )
40
+ end
41
+ end
42
+
43
+ latch . wait ( 1 )
37
44
expect ( t . status ) . to eq 'sleep'
38
45
t . kill
39
46
end
@@ -70,8 +77,15 @@ module Concurrent
70
77
describe '#wait' do
71
78
72
79
it 'should block the thread' do
73
- t = Thread . new { mutex . synchronize { subject . wait ( mutex , 1 ) } }
74
- sleep ( 0.1 )
80
+ latch = Concurrent ::CountDownLatch . new
81
+ t = Thread . new do
82
+ mutex . synchronize do
83
+ latch . count_down
84
+ subject . wait ( mutex , 1 )
85
+ end
86
+ end
87
+
88
+ latch . wait ( 1 )
75
89
expect ( t . status ) . to eq 'sleep'
76
90
t . kill
77
91
end
You can’t perform that action at this time.
0 commit comments