Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'll take a stab - hopefully this will give you enough to continue your research.</p> <p>I suspect the thread running TaskExitHandler is the parent thread for all of the worker threads. TEH would have a hard(er) time joining up with the children otherwise.</p> <p>The child / worker threads are not handling the exceptions thrown to them. However, an exception must be handled <strong>somewhere</strong> or the entire process will get shut down. The parent thread (aka TEH) is the last stop in the process's stack / chain for handling exceptions. Your sample code shows that TEH's exception handling is to simply throw / not handle the exception. So it cores out.</p> <p>It's not necessarily a data structure that's being shared, but rather the process / thread IDs and memory space. The child threads do share global memory / heap space with the parent and each other, hence the need for semaphores and / or mutexes for locking purposes.</p> <p>Good encapsulation dictates that the worker threads should be smart enough to handle any / all exceptions they might see. That way, the individual worker thread can be killed off instead of bringing down the parent thread and the rest of the process tree. OTW, you can continue catching the exception(s) in TEH, but it's really unlikely that thread has (or should have) the knowledge of what to do with the exception.</p> <p>Add a comment if the above isn't clear, I'm happy to explain further.</p> <p> I did a little research and confirmed that exceptions are generated against heap memory, not stack memory. All the threads of your process share the same heap*, so it makes more sense (at least to me) why the parent thread would see the exception when the child thread doesn't catch it. *FWIW, if you fork your process instead of starting a new thread, you'll get a new heap as well. However, forking is an expensive operation against the memory since you're copying all the heap contents over to the new process as well.</p> <p>This SO thread discusses setting up a thread to catch all exceptions, which will probably be of interest: <a href="https://stackoverflow.com/questions/188977/catching-exceptions-from-another-thread">catching exceptions from another thread</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload