Perl exited with active threads: 1 running and unjoined 2 finished and unjoined 0 running and detached

Can you describe what this means?

IIRC, the correct way to finish a multithreaded program, depends on what the program is doing ...

If your sample code was written like this

sub Main { my( $msglimit ) = @_; use threads::Q; my $qout = threads::Q->new( 50 ); threads->create( \&message_sender, $qout )->detach(); ## can't +join me :) my $hear = threads->create( \&message_receiver, $qout, $msglimit ) +; my( @ret ) = $hear->join; ## blocking print "Bye join @ret\n"; }

Then its easy to see that the correct way to finish a multithreaded program, is to join all the threads you wanted to wait for, save_state/print_report/flush_logs, and then exit

If you have finished threads, that aren't joined, that means they were taking up memory waiting to be joined, and you simply discarded the results

If you have threads waiting for jobs to process , threads blocking on a queue, these should probably be detached

Threads are like global objects or singletons, at the end of the program they cease to exist, so you have to decide what you're saving, what buffers you're flushing ...

Hi


In reply to Re: What is the correct way to finish multithreaded program? by Anonymous Monk
in thread What is the correct way to finish multithreaded program? by Gangabass

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.