Solved

Creation of Multiple threads

Posted on 2009-04-14
3
274 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 your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now