anshumangoyal has asked for the wisdom of the Perl Monks concerning the following question:
Now when I do foreach(keys %CallInfoHash) after the process has been completed, there is no value in %CallInfoHash. I am sure there is some issue with the shared variables but I am unable to find the solution. Please help.use threads; use threads::shared; my %CallInfoHash : shared = (); my $processToFork = 5; my $threads = 100; my %threadsHash; for ($jj = 0; $jj < $processToFork; $jj++) { ...fork a process here: for ($ii = 0; $ii < $threads; $jj++) { my $callNum = $jj; $UrlToDownload = <Some URL>; push (@argList, $callNum ); push (@argList, $UrlToDownload); $threadsHash{$CallNumber} = threads->create(\&tsub, @argList); } } sub tsub { .. Here some operations are done and values are generated. These values are to be stored in %CallInfoHash Hash. my $value1 = xx; my $value2 = xx; $CallInfoHash{$CallNumber}{'value1'} = $value1; $CallInfoHash{$CallNumber}{'value2'} = $value2; .... There are about 10 values. }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Forking Multiple Threads
by Corion (Patriarch) on Feb 08, 2012 at 11:48 UTC | |
by anshumangoyal (Scribe) on Feb 08, 2012 at 11:55 UTC | |
by Corion (Patriarch) on Feb 08, 2012 at 12:02 UTC | |
by anshumangoyal (Scribe) on Feb 08, 2012 at 12:18 UTC | |
by BrowserUk (Patriarch) on Feb 08, 2012 at 12:55 UTC | |
by Corion (Patriarch) on Feb 08, 2012 at 12:24 UTC | |
Re: Forking Multiple Threads
by locked_user sundialsvc4 (Abbot) on Feb 08, 2012 at 14:04 UTC | |
by BrowserUk (Patriarch) on Feb 08, 2012 at 19:05 UTC | |
by locked_user sundialsvc4 (Abbot) on Feb 08, 2012 at 21:55 UTC | |
by BrowserUk (Patriarch) on Feb 09, 2012 at 01:03 UTC | |
by locked_user sundialsvc4 (Abbot) on Feb 09, 2012 at 03:49 UTC | |
|