Skip to content

Instantly share code, notes, and snippets.

@m-ueno
Created October 17, 2013 00:17
Show Gist options
  • Save m-ueno/7017248 to your computer and use it in GitHub Desktop.
Save m-ueno/7017248 to your computer and use it in GitHub Desktop.
http://www.jstorimer.com/blogs/workingwithcode/8085491-nobody-understands-the-gil Appending to arrays is not thread-safe Very few things are implicitly thread-safe in Ruby. For example, appending to arrays:
array = []
5.times.map do
Thread.new do
1000.times do
array << nil
end
end
end.each(&:join)
puts array.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment