Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^5: What is the correct way to finish multithreaded program?

by BrowserUk (Pope)
on May 05, 2014 at 15:49 UTC ( #1085086=note: print w/replies, xml ) Need Help??

in reply to Re^4: What is the correct way to finish multithreaded program?
in thread What is the correct way to finish multithreaded program?

I'm pushing undef into the queue with ... and I think this will cause thread to return:

It will. Eventually. But there is no guarantee -- indeed it is most unlikely -- that all of the threads will: a) get a timeslice; b) receive the undef from the queue; c) act upon it and exit; before your main thread tries to join them.

The whole point of join is that it waits for the threads to finish, thus ensuring that your main thread doesn't exit before your child threads are finished.

It rarely makes any sense to turn it into a non-blocking operation by calling is_joinable before calling join.

The are a few specialist uses for that, but in the case of your code it only guarantees that any thread that is slow to finish will not get joined before you terminate the main thread; hence the error message.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re^5: What is the correct way to finish multithreaded program?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1085086]
[Discipulus]: and anyway we have CB where every (democratic) opinion can be expressed
erix eat the rich!
[1nickt]: I do think it is sad that roho has received 3 downvotes for his polite request, as did I when I objected to the profanity in stonecolddevin's sig. I upvoted both him and Karl for the discussion. Way too much downvoting for inappropriate reasons here!
Discipulus learn that 'argue' has a little negative sense, he thought was a neutral sense, 'vox media'
[1nickt]: argue == discuss && argue == be contentious
[Discipulus]: you are right 1nickt i didnt voted nor downvoted; I just upvote perl content i like
[1nickt]: In Spanish, to argue (like a fight) is discutir -- does not mean to discuss !
[1nickt]: Sigh, this is why I gave up human-only languages and became a Perl linguist :-)
[Discipulus]: i just, rarely, downvote unpolite posts and spam, and wrong advices
[Discipulus]: discutere in eatalian is neutral: but discutere with wife sounds implicitly negative..

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2017-06-22 12:21 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (519 votes). Check out past polls.