In MFC the class CSingleLock and CMultiLock represents
synchronization access objects, which enables the access-control mechanism in
multithreaded application. Its also should be noted that CSingleLock and
CMUltiLock does not have a base class. CSingleLock is used when we need to wait
on a single object at a time and CMultiLock is used for waiting for on multiple
objects or when we have an option of using any of the multiple objects available
at the same time.
To use these classes, create and object of this class in the function and then
use the IsLocked function to check if the resource is available or not.
Then wait for or get access to the shared resource with the Lock function. At
the end use the UnLock to release the resource.
Both these access object requires the presence of any of the synchronization
object derived from CSyncObject with it. In CMultiLock we need to provide
an array of synchronization objects.
|