what happens when a thread throws an exception?

say i create a thread using pthread_create and the function that the thread executes throws an exception, what happens to that thread then?
If it's unhandled, the thread terminates. That's bad.
But if I catch and handle the exception in the main function (which invoked pthread_create on the function which throws the exception), the thread executing the invoked function would terminate am I correct?
I don't think you can do the handing it in main(), it's not really in the thread's call stack.
Last edited on
so that means that the thread's call stack begins with the function which is passed to pthread_create?
and if I don't handle the exception in that function then the thread terminates? am I correct?
Correct. And it goes without freeing dynamically allocated resources aquired by the thread unless they're released thru the normal stack unwind mechanism.
ok thanks that clears things up
Topic archived. No new replies allowed.