A
Alex Young
I'm a little confused by Mutex's behaviour. It doesn't seem right that a
single thread should be able to block itself:
alex@twentyone:/tmp$ cat thread-block.rb
require 'thread'
m = Mutex.new
m.synchronize do
m.synchronize do
puts "Woo!"
end
end
alex@twentyone:/tmp$ ruby thread-block.rb
thread-block.rb:6:in `synchronize': stopping only thread (ThreadError)
note: use sleep to stop forever
from thread-block.rb:6
from thread-block.rb:5:in `synchronize'
from thread-block.rb:5
Why does it behave like this? Is it traditional for mutexes (mutices?)
to be designed this way?
single thread should be able to block itself:
alex@twentyone:/tmp$ cat thread-block.rb
require 'thread'
m = Mutex.new
m.synchronize do
m.synchronize do
puts "Woo!"
end
end
alex@twentyone:/tmp$ ruby thread-block.rb
thread-block.rb:6:in `synchronize': stopping only thread (ThreadError)
note: use sleep to stop forever
from thread-block.rb:6
from thread-block.rb:5:in `synchronize'
from thread-block.rb:5
Why does it behave like this? Is it traditional for mutexes (mutices?)
to be designed this way?