![]() ![]() ![]() Critical sections work like gates that allow only a single thread to enter at a time. If objects do not provide built-in locking, you can use a critical section. The lock is not released until the last locking call is matched with a corresponding unlock call in the same thread. Calls to TCanvas.Lock or TThreadList.LockList can be safely nested. Calling TThreadList.LockList returns the list object while also blocking other execution threads from using the list until the UnlockList method is called. ![]() VCL and CLX applications also include a thread-safe list object, TThreadList. Some objects have built-in locking that prevents the execution of other threads from using that object instance.įor example, canvas objects ( TCanvas and descendants) have a Lock method that prevents other threads from accessing the canvas until the Unlock method is called. ![]() Doing so can cause performance to degrade seriously and negate most of the advantages of using multiple threads. Be careful not to block other execution threads unnecessarily. To avoid clashing with other threads when accessing global objects or variables, you may need to block the execution of other threads until your thread code has finished an operation. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |