为了让您的多执行绪元件成为安全执行绪,您必须协调共用资源的存取。
In order for your multithreaded components to be thread-safe, you must coordinate access to Shared resources.
列举值通常没有集合的独占存取权,因此列举集合本质上并非安全执行绪的程序。
Typically the enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure.
由于大小和效能因素,MFC物件在物件层级上不是安全执行绪,只有在类别层级上才是。
For size and performance reasons, MFC objects are not thread-safe at the object level, only at the class level.
若要保证列举期间的安全执行绪,您可以在整个列举期间锁定集合,或拦截由其他执行绪所做变更造成的例外状况。
To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions that result from changes made by other threads.
因此,确认当您更新应用程序状态资料时,借由包含内建同步处理支援,以使用安全执行绪执行这项动作是很重要的。
Therefore, it is important to ensure that when you update application state data, you do so in a thread-safe manner by including built-in synchronization support.
将锁定的使用限制在只用于必须完整执行的程序码,您就能够写入确保资料安全的多执行绪元件,同时还是能够保持良好效能。
Restricting your locks only to code that must be executed atomically will allow you to write multithreaded components that ensure the safety of your data while still maintaining good performance.
MFC提供许多类别,这些类别允许执行绪同步物件的存取,以维护执行绪安全性。
MFC provides a number of classes that allow threads to synchronize access to objects to maintain thread safety.
列举值没有集合的独占存取权,因此,列举一个集合在本质上并不是执行绪安全的程序。
The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure.
列举值没有集合的独占存取权,因此,列举一个集合在本质上并不是执行绪安全的程序。
The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure.
应用推荐