I appreciate that BrowserUK is attempting to help, I'm not knocking that at all (yes-- thank you VERY MUCH BrowserUK). As I just posted in my reply to him-- the Re^2 code is exactly what I'm using to test with:

#! perl -slw use strict; use threads; sub test { my $t = shift; my $cmd = "c:/windows/system32/sort.exe test$t.dat"; print "Thread $t\n"; # show things are in motion... sleep 1; # kludge to insure all threads are up... system "$cmd >sorted$t.dat"; open F, "<sorted$t.dat" or die $!; print "Via system:\n", do{ local $/; <F> }; close F; print "Via backticks\n", `$cmd`; open F, "$cmd|" or die $!; print "Via pipe\n", <F>; close F; } sub spawnem { my $t1 = async{ \&test(1); }; my $t2 = async{ \&test(2); }; my $t3 = async{ \&test(3); }; my $t4 = async{ \&test(4); }; $t1->join; $t2->join; $t3->join; $t4->join; } &spawnem;

The test1-4.dat files all contain the same two lines

world
hello

And I loop the test from the DOS shell with the following .bat script:

LOOP: perl thread2.pl goto LOOP

A typical output I get when it hangs immediately looks like this:

Thread 1 Thread 2 Thread 3 Thread 4 Via system: hello world

where it just sits there and hangs until I ctl-C.

It'd be nice if the problem is a bug in my code, but I had started originally with a larger example and BrowserUK neatly reduced it to a short little thing that worked for him but didn't run multiple threads in parallel. So I modified it so that it would and that's where the code came from. Again, I may have introduced a bug and if so I'd sure like to know where my conception of how threads works is faulty...

-- Sync

In reply to Re^8: Behavior of threads on XP-- system() works, backtic & popen don't... by Sync
in thread Behavior of threads on XP-- system() works, backtic & popen don't... by Sync

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.