pavan6754 has asked for the wisdom of the Perl Monks concerning the following question:
Hi Guys,
Below Program creates 3 Threads and each execute ls command for given input path .But this program hangs,seems to be issue with executing ls command.can you please help me out here.
(Note: i don't want to use here lock,as it will be sequential execution not parallel )
use threads; use threads::shared; my %hash:shared =1; my @array=("c:\\Myscripts","c:\\Temp","c:\\Dropbox"); foreach(@array){ push @threads, threads->create(\&execute_ls, $_); } foreach (@threads) { $_->join(); } while(($key,$val)=each %hash){ print("$key:$val\n"); } sub execute_ls{ my $ip=shift; $hash{$ip}=`ls -1 $ip`; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Issue with Threads while collecting command output
by BrowserUk (Patriarch) on Nov 07, 2011 at 16:51 UTC | |
|
Re: Issue with Threads while collecting command output
by kennethk (Abbot) on Nov 07, 2011 at 16:54 UTC | |
|
Re: Issue with Threads while collecting command output
by zentara (Cardinal) on Nov 08, 2011 at 11:18 UTC | |
by BrowserUk (Patriarch) on Nov 08, 2011 at 14:10 UTC | |
by zentara (Cardinal) on Nov 08, 2011 at 16:42 UTC |