Solved

Creation of Multiple threads

Posted on 2009-04-14
3
300 Views
Last Modified: 2013-12-25
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
0
Comment
Question by:koti688
3 Comments
 
LVL 10

Accepted Solution

by:
oleber earned 250 total points
ID: 24135596
Instead of giving you a solution, I suggest you to read

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

0
 

Author Comment

by:koti688
ID: 24135614
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
 
LVL 39

Assisted Solution

by:Adam314
Adam314 earned 250 total points
ID: 24139612

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

Open in new window

0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question