ruby/benchmark/bm_vm4_thread_mutex3.rb
ko1 ef3fb5d1e8 * benchmark/bm_vm3_thread_*.rb: renamed bm_vm3_thread_*.rb to
benchmark/bm_vm_thread_*.rb.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-14 19:45:08 +00:00

20 lines
247 B
Ruby

# 1000 threads, one mutex
require 'thread'
m = Mutex.new
r = 0
max = 1000
(1..max).map{
Thread.new{
i=0
while i<max
i+=1
m.synchronize{
r += 1
}
end
}
}.each{|e|
e.join
}
raise r.to_s if r != max * max