in reply to Re: Threading Woes
in thread Threading Woes

Hi, I tried what you said about Thread::Pool, and all the threads get started correctly but once I get to the 'if statement' that kills the threads, the foreach loop, get stuck in a infinte loops. I pasted some of my code in here, with a dummy sub function I created to test the pools. Any idea why the 'if(@result = $pool->result_dontwait($_))' statement never hits true?? -Otter
my %hosts=(); my $counter=0; my $global=0; my $pool=(); my @result=(); my %ids=(); $pool = Thread::Pool->new( { do => sub {\&Temp_function(@_);}, workers => 10, # default: 1 }); %hosts = &Telnet_host(); foreach (keys %hosts) { $ids{$_}=$pool->job($_, $hosts{$_} ); } while (keys %ids) { foreach (keys %ids) { if (@result = $pool->result_dontwait($_)) { print $ids{$_} . "\n"; delete ($ids{$_}); } } print "Items still to do: " . $pool->todo . "\n"; } ##--END FUNCTION CALLs-- ### Temp Sub Functions sub Temp_function { my ($ip,$mac)= @_; print $mac . "\n"; return $mac; } ### End Temp Sub Functions