Created
May 19, 2020 07:54
-
-
Save mdaisuke/2905f703a1f82ce73078139e57387326 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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