Creation of Multiple threads

How to create a multiple threads on a function ?

my $thrcount = getValueFromPath($testcase,"TestCase/TCount");

which returns a count from an xml , which is loaded in $testcase.

i want create $thrcount of  threads on a function called putdata.

sub putData {
   ......
   ......
}

How to create Multiple threads on this function which are equal to $thr count ?

Please advise , i am new to Perl and threading
koti688Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
oleberConnect With a Mentor Commented:
Instead of giving you a solution, I suggest you to read

http://perldoc.perl.org/perlthrtut.html

0
 
koti688Author Commented:
hi oleber ,

i have read the documentation, but i can able to create one  thread on a function.

when i have a variable count , how to create that many number of threads on this function ? please help
0
 
Adam314Connect With a Mentor Commented:

my @all_threads;
for(1..$thrcount) {
    push @all_threads, threads->create(\&putData);
}

Open in new window

0
All Courses

From novice to tech pro — start learning today.