Maybe Net::FTP is unhappy?

use strict; use warnings; use Config; BEGIN { $Config{useithreads} or die ('Recompile Perl with threads to run this program.'); }; use threads; my $i = 0; my $size = 200; my $start_byte = 0; my @THRD_LIST; my $thrd; my $targetSize = $size / 10; while ($size) { my $chunk = $targetSize; $i++; $chunk = $size if $chunk > $size; $size -= $chunk; print "Process part $i. Size is $chunk\n"; $thrd = threads->create (\&transfer_chunks, $i, $chunk) or die "Failed to start the thread: $@\n"; push (@THRD_LIST, $thrd); } # start the threads for $thrd (@THRD_LIST) { $thrd->join (); } print "All done\n"; sub transfer_chunks { my ($i, $chunk) = @_; while ($chunk--) { print "$i "; sleep 1 + rand (3); } print "\nprocess $i complete\n"; }

prints (for example):

Process part 1. Size is 4 1 Process part 2. Size is 4 Process part 3. Size is 4 2 Process part 4. Size is 4 3 Process part 5. Size is 4 4 Process part 6. Size is 4 5 Process part 7. Size is 4 6 Process part 8. Size is 4 7 Process part 9. Size is 4 8 Process part 10. Size is 4 9 10 1 3 4 5 6 10 3 4 8 9 2 3 6 7 8 10 1 5 7 8 9 process 3 complete 4 10 2 process 4 complete 6 1 5 7 process 8 complete 9 2 process 6 complete process 9 complete process 10 complete process 1 complete process 5 complete process 7 complete process 2 complete All done

which is as expected on my XP system. Can you reproduce the problem without using FTP?


Perl reduces RSI - it saves typing

In reply to Re: Split large file and upload to ftp server with multiple threads by GrandFather
in thread Split large file and upload to ftp server with multiple threads by mdc76

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.