home Tech Library Tech Forum
Publisher
 
Basics of Multithreading       
 
 
CSingleLock and CMultiLock in MFC
 
 

 

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.
 
   
  RELATED TOPICS  
What is a thread?
Thread Pools
Multithreading
Thread Vs Process
MultiThreading support in C++ and MFC
Creating User-Interface Threads in MFC
Creating worker Threads in MFC
Terminating Threads
Thread Synchronization
Designing a Thread-safe class
Semaphore in MFC
Mutex in MFC
Critical Section in MFC
Event Objects in MFC


 
           
Home | Profile | Users | Library | Publisher | Tech Forum | News | Contact Us