#! perl -slw use threads; use strict; use warnings; #my $command = q[printA.exe]; my $command = q[perl -wle"sleep int rand 3; print 'step1'"]; my $numCompleteTestRuns = 100; runTests(); sub runTests { my @threadList = (); for my $i (0 .. $numCompleteTestRuns) { print("About to create thread $i:"); my $thread = threads->new(\&stepThread); push (@threadList, $thread); } my $numThreads = @threadList; print("There are $numThreads threads"); # wait for each running thread to end foreach my $thread (@threadList) { $thread->join; print("A thread joined"); } print("Processes ended - Goodbye"); } # thread runs a type of users steps once only sub stepThread { print("Starting thread and about to run: $command"); my $output = `$command`; print("$output"); print("Ending thread"); }
In reply to Re^12: "Thread already joined at..." and "A thread exited while x threads were running" errors
by nickos
in thread "Thread already joined at..." and "A thread exited while x threads were running" errors
by nickos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |