Basic COM  «Prev 

Who creates COM objects and apartments?

COM objects are actually created in the context of a COM apartment. A COM apartment defines the threading context of an executing COM object. A single-threaded apartment (STA) allows only one thread to access interface methods within the object. This is always the same thread. A multithreaded apartment (MTA) allows multiple threads to access interface methods within the object. This access can, and often does, occur simultaneously. For example, thread A and thread B can simultaneously access the same or different methods within the object.

COM Programming with Microsoft .NET
Unlike COM interfaces and objects, which are visible in our code via instances of C++ classes, (usually) there is no apartment object. Instead, the type of apartment dictates how we code our COM interface methods. For example, in an STA, because only one specific thread can access an instance of a COM object, no special coding is required to guard data and methods. In an MTA, data and methods are often guarded using Win32 synchronization objects to protect the integrity of the object. See the Microsoft Platform SDK documentation for details.