COM - STA vs. MTA

STA Single Threaded Apartment

MTA Multi Threaded Apartment


The term apartment describes the threading model used by COM.

Before making your first COM call (as a client or as a server), you must enter an apartment, either the STA or the MTA. The choice of apartment determines how you will make and receive COM calls.

If your object is not thread safe (and this is a sensible default), then you should enter the Single Threaded Apartment, and calls to your object will arrive on a single thread. Calls will arrive sequentially and you will receive only one call at a time.

If your object is thread safe, you may choose to enter the Multi Threaded Apartment, and calls to your object may arrive on any thread, and you must handle thread synchronization internally. I.e. You may receive a call on one thread while an earlier call is still being processed on another thread.

An apartment is a logical container for COM objects. Objects in the STA will never be called directly. All calls will be synchronized by COM. Objects in the MTA may be called directly and should be implemented to be thread safe.


Ads by Google


Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath