in reply to Re^11: "Thread already joined at..." and "A thread exited while x threads were running" errors
in thread "Thread already joined at..." and "A thread exited while x threads were running" errors
#! 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"); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^13: "Thread already joined at..." and "A thread exited while x threads were running" errors
by BrowserUk (Patriarch) on Sep 07, 2004 at 16:00 UTC | |
by nickos (Initiate) on Sep 07, 2004 at 16:20 UTC | |
by BrowserUk (Patriarch) on Sep 07, 2004 at 19:19 UTC | |
by nickos (Initiate) on Sep 08, 2004 at 13:30 UTC |