I just re-built 5.8.4 from scratch and ran your test 100 times without failure.
Update: I can now reproduce the failure--reliably--with 5.8.4. This doesn't happen with 5.8.3/AS809.
The trick seems to be taking the focus away from the session running the test. If I bring up the task manager while running the loop below, every run will fail whilst the task manager has the focus and every run will complete if the cmd session has the focus.
A timing issue for sure.
P:\test>perl5.8.4 -v
This is perl, v5.8.4 built for MSWin32-x86-multi-thread
Copyright 1987-2004, Larry Wall
Perl may be copied only under the terms of either the Artistic License
+ or the
GNU General Public License, which may be found in the Perl 5 source ki
+t.
Complete documentation for Perl, including FAQ lists, should be found
+on
this system using `man perl' or `perldoc perl'. If you have access to
+ the
Internet, point your browser at http://www.perl.com/, the Perl Home Pa
+ge.
P:\test>for /l %i in (1,1,100) do perl5.8.4 367162.pl
P:\test>perl5.8.4 367162.pl
parent 1980: continue
parent 1980: continue
parent 1980: waiting for join
kid 1 before sort
kid 1 after sort
parent 1980: thread exited
parent 1980: waiting for join
kid 2 before sort
kid 2 after sort
parent 1980: thread exited
P:\test>perl5.8.4 367162.pl
parent 1396: continue
kid 1 before sort
kid 1 after sort
parent 1396: continue
parent 1396: waiting for join
kid 2 before sort
kid 2 after sort
parent 1396: thread exited
parent 1396: waiting for join
parent 1396: thread exited
P:\test>perl5.8.4 367162.pl
...
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, algoritm, algorithm on the code side." - tachyon