develooper Front page | perl.ithreads | Postings from January 2010

Re: Threading within another thread

Thread Previous | Thread Next
Francesco Nidito
January 29, 2010 03:05
Re: Threading within another thread
Message ID:
It is possible to spawn a thread from inside another thread but
remember that the thread will belong to the process and not to the
thread that spawned it (as usually with threads...).

use threads;

sub InternalThread {
     # do something...

sub ExternalThread {
    # do something...
    my $it = threads->create(\&InternalThread);
    # do something else in parallel with InternalThread...
    # do the rest

# main()
my $et = threads->create(\&ExternalThread);

On Thu, Jan 28, 2010 at 6:42 PM, Danny Wong (dannwong)
<> wrote:
> Hi Perl Thread GURUS,
>        Is it possible to run threads within another thread? Is so, any
> example on how to do it? Thanks.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About