in reply to Re^9: "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

No, I'm afraid not - and the finished script will need to be able to run on Win2k amongst others.

What else could be causing the problem? If there was a general problem with threads with Perl on Win2k it would be reasonably well known wouldn't it? It's not like I'm not doing anything really complicated. I'm stumped :(

What should I do next? Perhaps I should reduce the code to the bare minimum that causes this problem and post it to a more general place...

  • Comment on Re^10: "Thread already joined at..." and "A thread exited while x threads were running" errors

Replies are listed 'Best First'.
Re^11: "Thread already joined at..." and "A thread exited while x threads were running" errors
by BrowserUk (Patriarch) on Sep 07, 2004 at 14:49 UTC

    I'm not aware of any particular problems with threads under W2k. Mostly, the various win32 platforms seem to suffer the same problems (or not). That's why I suggested trying a different machine--another w2k would be fine--to see if the problem is peculiar to your machine alone.

    Reducing it to bare minimum makes sense, though what you have is not that complex. Nothing your doing looks in anyway wrong. Somewhat verbose, but most of that is tracing, probably added to try and track down the problem.

    If you can get a small testcase that displays the problem you could raise a perlbug and post it to perlbug@perl.org. Be sure to mention that *only win2k* is affected. You could also post it back here.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon
      Hmm, castaway just ran your version of my script on the same setup (This is perl, v5.8.4 built for MSWin32-x86-multi-thread (Win2k)) as me and had the same problem. Time to start whittling down the code then I spose...
      Okay, can this testcase be made any smaller (apart from by removing the print statements)?
      #! 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"); }

        That looks fine. I just ran it a dozen or so times on my setup and it completes perfectly every time.

        Perhaps the only other thing I would try is to reduce the command that you run to a simple `dir > nul`; and see what, if any, difference that makes.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        "Memory, processor, disk in that order on the hardware side. Algorithm, algorithm, algorithm on the code side." - tachyon