develooper Front page | perl.perl5.porters | Postings from May 2004

Re: stopping a thread (fwd)

Thread Next
From:
Thomas S Brettin
Date:
May 4, 2004 03:00
Subject:
Re: stopping a thread (fwd)
Message ID:
Pine.LNX.4.44.0405032144210.4049-100000@norris-mail.lanl.gov
Can this be true? "There's no notion of 'thread cancellation' in perl"

Tom Brettin
---------- Forwarded message ----------
Date: Mon, 3 May 2004 09:29:42 -0500 (CDT)
From: Mike Pomraning <mjp@pilcrow.madison.wi.us>
To: Thomas S Brettin <brettin@lanl.gov>
Cc: perl-ithreads@perl.org
Subject: Re: stopping a thread

On Sun, 2 May 2004, Thomas S Brettin wrote:

> Is there an easy way to stop a thread from outside the thread? I'ld like
> to do something simple like:
>
> my $thread = threads->new($code_ref);
> ...
> $thread->stop();
>
> Thanks for any help.

There's no notion of 'thread cancellation' in perl.  If you can run
Thread::Signal (see that module's CAVEATS), then Thread::Stop offers a kill()
method which behaves as you expect.

-Mike
-- 
Michael J. Pomraning
mjp@pilcrow.madison.wi.us
http://pilcrow.madison.wi.us


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About