Threads in MFC Part III: Exceptions, Suspense, Murder, and Safety
Posted on May 6th, 2002 by pepethecow
Exceptions
In the previous tutorial, I described the various synchronization objects you can use to control access to shared objects. In most cases, these will work fine, but consider the following situation:
[code lang=”cpp”]
UINT ThreadFunc(LPVOID lParam)
{
::criticalSection.Lock();
::globalData.DoSomething();
SomeFunctionThatThrowsException();
::criticalSection.Unlock();
return 0;
}[/code]
What’s going to happen when that exception gets thrown? The critical section will never be unlocked. If you start the thread […]
Filed under: Code | No Comments »





