Skip to content

Instantly share code, notes, and snippets.

@fukuiretu
Last active February 29, 2016 08:58
Show Gist options
  • Save fukuiretu/e3a18e26b246ae512988 to your computer and use it in GitHub Desktop.
Save fukuiretu/e3a18e26b246ae512988 to your computer and use it in GitHub Desktop.
parallelのスレッドセーフtest
require 'parallel'
class Dummy
def initialize
@cnt = 0
end
def increment
@cnt += 1
end
def test
arr = (1..10000000).to_a
Parallel.each(arr, in_threads: 10) do
increment
end
p @cnt # 10000000
end
end
Dummy.new.test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment