摘要
本文介绍了COM的几种线程模型:单线程套间模型(STASingleThreadApartment),多线程套间模型(MTAMultithreadApartment)和自动线程模型(Auto-thread)。首先,介绍了单线程套间模型和多线程套间模型的意义和特点,其中,单线程套间模型是一种缺省的模型,而多线程套间模型可以说是对单线程套间模型的简化;然后,根据分析单线程套间和多线程套间模型的特点,引入了自动线程模型,这种模型可以在多个客户同时访问多个COM对象时,极大地提高访问的性能和效率。本文同时提供了样例代码,以便于理解这些概念。
This article attempts to illustrate the functions of the COM Single Thread Apartment (STA), Multithread Apartment (MTA) and ATL Auto-thread Module. In the first part of this article, the functionality of the STA and MTA apartment is reviewed. STA is a kind of default model, to some extent, MTA is the simplified model of STA. In the left part of this article, ATL Auto-threaded Server Module is introduced. This module can improve application performance significantly if multiple client instances access non-singleton COM objects simultaneously. In order to understand these conceptions, some sample codes are provided.
出处
《现代计算机》
2004年第8期43-46,共4页
Modern Computer