ruby中thread线程同步mutex锁代码示例
代码语言:ruby
所属分类:其他
代码描述:ruby中thread线程同步mutex锁代码示例
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
require 'thread' mutex = Mutex.new count1 = count2 = 0 difference = 0 #开始计时 counter = Thread.new do loop do mutex.synchronize do count1 += 1 count2 += 1 end end end #查看两个计数是否不一样 spy = Thread.new do loop d.........完整代码请登录后点击上方下载按钮下载查看
网友评论0