On 18 May 2005 07:44:42 -0700, ramialhasan wrote:
If I have some c++ class exported from a Win32 dll, and from some other
console application I created two threads and each thread creates an
instance of the exported class.
My question is related to using WaitForSingleObject from within the dll
class methods and if the two threads called a method in the dll that
blocks on WaitForSingleObject for a long time, then are the two
instances waiting for each other or if returned from
WaitForSingleObject it can continue event if the other thread still
blocked on its instance?
The threads wait on the object referred to by the HANDLE that you passed to
WFSO to become signaled or for the timeout interval you specified to
expire. Exactly what happens when the handle becomes signaled depends on
the type of the sync object. For example, only one thread is allowed to
acquire a mutex and progress, while the rest remain blocked (modulo
non-INFINITE timeout values) until that thread releases it (or terminates,
in which case it "abandons" the mutex), at which point, another thread can
acquire the mutex.
--
Doug Harrison
Microsoft MVP - Visual C++