Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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


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

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?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-06-07 15:31 GMT
Find Nodes?
    Voting Booth?
    How often do you go to conferences?

    Results (29 votes). Check out past polls.