P
Peña, Botp
Hi Friends,
This is my first touch on threads, so be gentle pls
I am trying to execute loop a command by using threads (tested them on
windows and I find them much faster than doing one at a time .
However, there are some commands that execuite very long time and are memory
intensive, so I want that I only execute 10 threads at a time.
eg.
LIMIT= 10
tlist = []
loop {
if tlist.size< LIMIT
tlist << Thread.new { p "test" }
else
sleep 5
end
}
Am, I right? Of course, I'm wrong since I tested it; tlist size is steady at
LIMIT. When I view tlist, the threads are dead, so how do I shrink tlist
properly? Will the threads just go away if I delete any item in tlist and
compact tlist? Can anyone give some hints pls?
Thanks.
kind regards -botp
This is my first touch on threads, so be gentle pls
I am trying to execute loop a command by using threads (tested them on
windows and I find them much faster than doing one at a time .
However, there are some commands that execuite very long time and are memory
intensive, so I want that I only execute 10 threads at a time.
eg.
LIMIT= 10
tlist = []
loop {
if tlist.size< LIMIT
tlist << Thread.new { p "test" }
else
sleep 5
end
}
Am, I right? Of course, I'm wrong since I tested it; tlist size is steady at
LIMIT. When I view tlist, the threads are dead, so how do I shrink tlist
properly? Will the threads just go away if I delete any item in tlist and
compact tlist? Can anyone give some hints pls?
Thanks.
kind regards -botp