killing threads in perl

  • Thread starter prameela.vankineni
  • Start date
P

prameela.vankineni

Hi,

Iam trying to transfer files(Io:Ftp)using threads in perl can any
one suggest me how to stop threads if i pressed cancelTransfer
button.Here iam giving part of my code.


sub get_value

{

print "Monitoring...\n";

while(1)

{

next unless (defined($list));

#sleep(2);

my $iter = $list->get_iter_first;

my $filename = $list->get($iter, 0) if defined($iter);

next unless(defined($filename));

print "File is $filename\n";

print "Splitting file...\n";

my $filenames_ref = split_file($filename);

my @filenames = @$filenames_ref;

$count = 0;

$finished = 0;

foreach (@filenames)

{

print "Transferring $_ ...\n";

transfer_file_cb($_,$count);

$count++;

}

sleep(2);

$list->remove($iter) if defined($iter);

}

}




sub transfer_file_cb

{

my $thread = new threads(\&transfer_file,\@_);

push (@threads, $thread);

}



# wait for the children to finish...

foreach (@threads)

{

$_->join;

}
 
Z

zentara

Hi,

Iam trying to transfer files(Io:Ftp)using threads in perl can any
one suggest me how to stop threads if i pressed cancelTransfer
button.Here iam giving part of my code.
sub transfer_file_cb

{
my $thread = new threads(\&transfer_file,\@_);

push (@threads, $thread);
}

The important code, which we need to see, is the thread code sub
transfer_file, which you have omitted.
 

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 2
Is it a gtk2 problem or Threads problem 0
threads problem 1
Killing threads in perl 5
Perl threads 6
perl threads 2
Segmentation fault: problem with perl threads 6
Memory leak with threads 16

Members online

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top