killing threads in perl

Discussion in 'Perl Misc' started by prameela.vankineni@gmail.com, Mar 9, 2006.

  1. Guest

    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;

    }
    , Mar 9, 2006
    #1
    1. Advertising

  2. zentara Guest

    On 9 Mar 2006 04:53:46 -0800, wrote:

    >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.



    --
    I'm not really a human, but I play one on earth.
    http://zentara.net/japh.html
    zentara, Mar 10, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. cppaddict
    Replies:
    20
    Views:
    806
    Chris Uppal
    Aug 11, 2004
  2. Don Garrett

    Killing threads during development.

    Don Garrett, Jun 5, 2005, in forum: Python
    Replies:
    0
    Views:
    292
    Don Garrett
    Jun 5, 2005
  3. jimzat

    Killing subservient threads

    jimzat, Feb 20, 2009, in forum: Python
    Replies:
    6
    Views:
    316
  4. Killing threads in perl

    , Mar 9, 2006, in forum: Perl Misc
    Replies:
    1
    Views:
    94
    zentara
    Mar 9, 2006
  5. Killing threads in perl

    , Mar 7, 2007, in forum: Perl Misc
    Replies:
    5
    Views:
    354
    zentara
    Mar 9, 2007
Loading...

Share This Page