Killing threads in perl

  • Thread starter prameela.vankineni
  • Start date
P

prameela.vankineni

hi ,


can anyone explain me how to kill threads in perl. i am trying to
transfer files (IO::FTP) using threads in perl,

how do i kill the thread when the file transfer is cancelled
 
Z

zentara

hi ,


can anyone explain me how to kill threads in perl. i am trying to
transfer files (IO::FTP) using threads in perl,

how do i kill the thread when the file transfer is cancelled

It depends if the thread was detached or not.

For a thread to terminate, it must
"reach the end of it's code block"
or
"return"

If it's not a detached thread, after you "return", you need to
join it, from the main thread, like
$worker_thread->join;


To force the thread to "return" when cancelled, you can
use a shared variable like $thread_die = 0, and when the
transfer is cancelled, set it to 1. Then in the thread code block,
check for it periodically, and if($thread_die == 1){ return}
A detached thread will then dissappear, and others need to
be joined.

There are many ways to do this, but you need to show your
thread code for more exact answers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

killing threads in perl 1
Killing threads 2
Killing threads, and os.system() 8
Killing threads in perl 5
perl threads 2
killing individual threads 0
Killing threads 13
Exiting threads via signal 6

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top