Exceptions Tidy Threads

You have some event-queue based threads running, and one hits an unrecoverable condition. Or one gets an event from another that says to die now please. So one thing you can do is have the thread just stop, but if you do that and it's used some heap space or system resources or toggled some reference counts on something shared, you have a problem. You want to deallocate its resources.

Therefore,

Use the stack-unwinding that comes with a thrown exception; if you use ResourceAcquisitionIsInitialization sensibly your destructors will do what's wanted. You can combine this with some reporting by having a catch down at the base of the thread's call-stack that displays/dispatches the exception's contents to some useful place.

I don't know of a better way to tidy threads than this - do you? --PeterMerel


You can also CancelThreadsWithAnException.

See also ThreadDeath


CategoryException CategoryThreads?


EditText of this page (last edited September 9, 2005) or FindPage with title or text search