|Keep It Simple, Stupid|
Re: What is the correct way to finish multithreaded program?by Anonymous Monk
|on May 05, 2014 at 08:05 UTC ( #1085015=note: 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
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 Section Seekers of Perl Wisdom