Skip to content

Instantly share code, notes, and snippets.

@mdaisuke
Created May 19, 2020 07:54
Show Gist options
  • Save mdaisuke/2905f703a1f82ce73078139e57387326 to your computer and use it in GitHub Desktop.
Save mdaisuke/2905f703a1f82ce73078139e57387326 to your computer and use it in GitHub Desktop.
counter = 0
flag = true
threads = 10.times.map do
Thread.new do
if flag
puts 'not thread safe' # IOを挟むとGVLが解放される
counter += 1
flag = false
end
end
end
threads.each(&:join)
puts counter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment