Newer
Older
2018-fumichan-thesis / sinatra-practice / form-sample / vendor / bundle / ruby / 2.5.0 / gems / thread_safe-0.3.6 / spec / thread_safe / hash_spec.rb
module ThreadSafe
  describe Hash do 
    let!(:hsh) { described_class.new }

    it 'concurrency' do
      (1..THREADS).map do |i|
        Thread.new do
          1000.times do |j|
            hsh[i * 1000 + j] = i
            hsh[i * 1000 + j]
            hsh.delete(i * 1000 + j)
          end
        end
      end.map(&:join)
    end
  end
end