-
Notifications
You must be signed in to change notification settings - Fork 419
Closed
Labels
questionAn user question, does not change the library.An user question, does not change the library.
Milestone
Description
Hello. Sorry for my english, but tell me please. This is normal behavior?
def test(i)
sleep(1)
return i
end
def test1()
g=[]
pool = Concurrent::FixedThreadPool.new(20)
for i in 1..5 do
pool.post do
g[i]=test(i)
end
end
sleep 5
p g
end
test1()
Result:
[nil, nil, nil, 3, nil, 5]
or
[nil, nil, nil, nil, 4, 5]
or
[nil, nil, 2, 3, nil, nil]
If I add a "sleep()"
def test(i)
sleep(1)
return i
end
def test1()
g=[]
pool = Concurrent::FixedThreadPool.new(20)
for i in 1..5 do
sleep(0.1)
pool.post do
g[i]=test(i)
end
end
sleep 5
p g
end
test1()
Result:
[nil, nil, 2, 3, 4, 5]
- Operating system: linux
concurrent-ruby
version: 1.0.3concurrent-ruby-ext
installed: yes / noconcurrent-ruby-edge
used: yes / no
Metadata
Metadata
Assignees
Labels
questionAn user question, does not change the library.An user question, does not change the library.