dvinay has asked for the wisdom of the Perl Monks concerning the following question:
I want to run perl threads in an For loop, for example suppose, i create 2 threads each containing an command to execute, once these 2 threads are completed i need to another set of same 2 threads and run it, and this should go on for the number of times i have given as an input to the main script below is the small code snippet
my @threads; #---Making Concurrent OneClick backup commands using threads------#for (my $i=0;$i<=3;$i++) { #-----performing the CHO loops as given by user-------# foreach (@finalOneClickarray) { push @threads, threads->new(\&concurrentBackupCommandsR +ead, $_); } foreach (@threads) { $_->join(); } } sub concurrentBackupCommandsRead() { doing my stuff here......... }
i have tried to put for loop, but it errors out saying Perl exited with active threads: please let me know what am i doing wrong here
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Running perl threads in loop
by NetWallah (Canon) on Sep 15, 2013 at 16:43 UTC | |
|
Re: Running perl threads in loop
by BrowserUk (Patriarch) on Sep 15, 2013 at 14:47 UTC | |
|
Re: Running perl threads in loop
by CountZero (Bishop) on Sep 15, 2013 at 14:32 UTC | |
by dvinay (Acolyte) on Sep 15, 2013 at 14:40 UTC | |
|
Re: Running perl threads in loop
by Anonymous Monk on Sep 16, 2013 at 12:10 UTC |