Altering your code to run as a standalone sample without needing access to a mail server and using threads (hence create rather than new) I get:

use warnings; use strict; use threads; use Thread::Queue; sub smtpblast{ my $mdq= shift; my $pending= $mdq->pending; while ($pending > 0){ my $md= $mdq->dequeue_nb; print "processing $md\n"; sleep $md; $pending= $mdq->pending; } my $threadid = threads->self; print "\n The process for thread $threadid is finished!\n"; } my $mdqueue=Thread::Queue->new(); $mdqueue->enqueue(10, 2, 5, 3, 7, 5); my $thr1=threads->create (\&smtpblast, $mdqueue); my $thr2=threads->create (\&smtpblast, $mdqueue); my $thr3=threads->create (\&smtpblast, $mdqueue); my $thr4=threads->create (\&smtpblast, $mdqueue); $thr1->join; print "\n Thread $thr1 joined! \n"; $thr2->join; print "\n Thread $thr2 joined! \n"; $thr3->join; print "\n Thread $thr3 joined! \n"; $thr4->join; print "\n Thread $thr4 joined! \n";

which prints:

processing 10 processing 2 processing 5 processing 3 processing 7 processing 5 The process for thread threads=SCALAR(0x3fdc57c) is finished! The process for thread threads=SCALAR(0x4508800) is finished! The process for thread threads=SCALAR(0x3ab0328) is finished! The process for thread threads=SCALAR(0x2534bbc) is finished! Attempt to free unreferenced scalar: SV 0x2023ed0, Perl interpreter: 0 +x2018414 at C:\Documents and Settings\Peter\My Documents\PerlScratch\ +noname.pl line 22. Thread threads=SCALAR(0x201f7e8) joined! Attempt to free unreferenced scalar: SV 0x22c2318, Perl interpreter: 0 +x22bf014 at C:\Documents and Settings\Peter\My Documents\PerlScratch\ +noname.pl line 23. Thread threads=SCALAR(0x201f7f4) joined! Attempt to free unreferenced scalar: SV 0x383cc50, Perl interpreter: 0 +x3afc294 at C:\Documents and Settings\Peter\My Documents\PerlScratch\ +noname.pl line 24. Thread threads=SCALAR(0x201f800) joined! Attempt to free unreferenced scalar: SV 0x3d68e68, Perl interpreter: 0 +x3d65314 at C:\Documents and Settings\Peter\My Documents\PerlScratch\ +noname.pl line 25. Thread threads=SCALAR(0x201f80c) joined!

and terminates as expected despite the errors.

Can you generate a similar sample the demonstrates the problem you are seeing?


DWIM is Perl's answer to Gödel

In reply to Re: Hanging Threads by GrandFather
in thread Hanging Threads by WalkingZero

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.