{"provider_url":"https://hatena.blog","published":"2014-08-28 01:44:27","blog_title":"Tbpgr Blog","title":"Ruby | Mutex | try_lock","author_url":"https://blog.hatena.ne.jp/tbpg/","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftbpgr.hatenablog.com%2Fentry%2F20140828%2F1409244267\" title=\"Ruby | Mutex | try_lock - Tbpgr Blog\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","version":"1.0","blog_url":"https://tbpgr.hatenablog.com/","image_url":null,"author_name":"tbpg","type":"rich","provider_name":"Hatena Blog","width":"100%","url":"https://tbpgr.hatenablog.com/entry/20140828/1409244267","categories":["Ruby"],"height":"190","description":"\u6982\u8981 Mutex#try_lock -> bool \u8a73\u7d30 mutex \u3092\u30ed\u30c3\u30af\u3057\u3088\u3046\u3068\u3057\u3066\u3001\u30ed\u30c3\u30af\u304c\u6210\u529f\u3057\u305f\u5834\u5408\u3001\u771f\u3092\u8fd4\u3057\u307e\u3059\u3002 \u30ed\u30c3\u30af\u3067\u304d\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u306f\u30d6\u30ed\u30c3\u30af\u305b\u305a\u507d\u3092\u8fd4\u3057\u307e\u3059\u3002 \u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9 require \"thread\" require \"date\" class MutexSample attr_reader :count def initialize @m = Mutex.new end def sleep_test(id) puts \"id = #{id}, locked? = #{@m.locked?}\" ret = @m.try_lock puts \"id = #{id},\u2026"}