<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>moyomot</author_name>
  <author_url>https://blog.hatena.ne.jp/moyomot/</author_url>
  <blog_title>もょもとの技術ノート</blog_title>
  <blog_url>https://moyomot.hatenablog.com/</blog_url>
  <categories>
    <anon>Ruby</anon>
    <anon>マルチスレッド</anon>
  </categories>
  <description>RubyのスレッドにはGiant VM lock (GVL) (Global Interpreter lock) が実装されており、同時に実行される ネイティブスレッドは常にひとつです。なので、スレッドセーフでないプログラムを実行しても、排他制御が効いているように見えます。 例えば次のコードを実行すると variable = 0 flag = true threads = 5.times.map do Thread.new do if flag variable += 1 flag = false end end end threads.each(&amp;:join) puts variable 1…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmoyomot.hatenablog.com%2Fentry%2F2014%2F05%2F04%2F232538&quot; title=&quot;Rubyでスレッドセーフでないことを簡単に確認したい - もょもとの技術ノート&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2014-05-04 23:25:38</published>
  <title>Rubyでスレッドセーフでないことを簡単に確認したい</title>
  <type>rich</type>
  <url>https://moyomot.hatenablog.com/entry/2014/05/04/232538</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
