Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-03-28 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found