help why warning with detached threads

[email protected] (李 征宇)
Newsgroups perl.ithreads
Message-ID <[email protected]>
Hi, guys

Recently I just wanna write a simple multi-threaded perl program.

The environment which the script runs in is 
OS: Linux i386
perl: 5.8.7
thread.pm : 1.05

And I find that when I create a child thread, detach from it and exit,
the warning message shows up: A thread exited while 2 threads were running. 
 
And I find in the user doc of threads:

" If the program exits without all other threads having been either 
joined or detached, then a warning will be issued. (A program exits 
either because one of its threads explicitly calls exit(), or in the 
case of the main thread, reaches the end of the main program file.) "

It seems the warning message couldn't have been shown up. I try to use 
join,
it works as stated, I wonder why? Anybody could help me out of this?

Thanks very much.

The test scripts is as follow for your kind reference.

#! /usr/bin/perl -w
use threads;

my @p1=("a","b","c","d");

$thr=threads->new(\&test,\@p1,"Hello","World");
print " current thread id:".threads->tid().".\n";
print " child thread id:".$thr->tid.".\n";
$thr->detach();
#$thr->join();

sub test{        
        my ($p1,$p2,$p3)=@_;
        my @p1=@{$p1};

        print "p1:@p1\n";
        print "p2:$p2\n";
        print "p3:$p3\n";

        sleep 10;
}                  

Regards,
Zhengyu Li

_________________________________________________________________
涓虹杩琛浜ゆ锛璇蜂娇 MSN Messenger:  http://messenger.msn.com/cn
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.