At 02:51 PM 7/24/02 +0100, Ray Hilton wrote:
>Ok, I try:
>
>use threads;
>
>&foo;
>sub foo {
> my $thr = threads->new(\&bar);
> $thr->detach;
>}
>
>sub bar {
> sleep(3);
> print "bar\n";
>}
>
>And I get:
>
>A thread exited while 2 other threads were still running.
That's because there is no executable code after the &foo. So it reaches
the end of the script immediately (before the 3 seconds of bar have
elapsed) and executes an implicit exit. Since an exit in any thread will
take down the entire process, including any other threads, bar will be
interrupted before it ever gets the chance to print anything. And because
there are threads running when you exit, you get the error
message. Confusing thing is that it says there are two, when in fact there
was only one (at least visible). I guess that wrong number (still) is a bug...
>And no evidence of bar\n being printed. What is this create function
>you have? Is that the same as new()?
create is a synonym for new (how's that for politics... ;-)
Liz