Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

2014-08-24から1日間の記事一覧

Ruby | Mutex | lock

概要 Mutex#lock -> self 詳細 mutex オブジェクトをロックする。 1つのスレッドだけがロック可能。 サンプルコード require "thread" class Counter attr_reader :count def initialize @count = 0 @m = Mutex.new end def increment(id) @m.lock begin pu…