⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (556 Bytes)
Bug #15360
ยป deadlock_test.rb
Run with "ruby deadlock_test.rb" -
brockspratlen (Brock Spratlen)
, 11/29/2018 06:09 PM
require
"thread"
require
"timeout"
class
Hallo
extend
MonitorMixin
def
self
.
global_sleep
(
duration
)
self
.
mon_synchronize
do
sleep
(
duration
)
end
end
end
threads
=
20
.
times
.
collect
do
Thread
.
new
do
200
.
times
do
begin
Timeout
.
timeout
(
0.1
)
do
Hallo
.
global_sleep
(
0.2
)
end
rescue
ThreadError
=>
e
puts
"
#{
e
.
class
}
:
#{
e
.
message
}
:
\n
"
+
e
.
backtrace
.
join
(
"
\n
"
)
+
"
\n\n
"
rescue
Timeout
::
Error
=>
e
puts
e
.
class
nil
end
end
end
end
threads
.
each
{
|
t
|
t
.
join
}
(1-1/1)
Loading...