what is the difference b/w STA and MTA .How they change the behavior of multithreaded application ? RRS feed

  • Question

  • Hi,

    All I just want to know the diff. b/w a STA and MTA .how they change the behavior of an Application.

    Friday, February 8, 2013 11:04 AM


  • Hi Deepak,

    Simply speakins STA is Single thread apartment(application) and MTA is multi thread appartment & with MTA you can do multiple activities (run multiple threads in parallel).

    The COM threading model is called an "apartment" model, where the execution context of initialized COM objects is associated with either a single thread (Single Thread Apartment) or many threads (Multi Thread Apartment). In this model, a COM object, once initialized in an apartment, is part of that apartment for the duration of it's runtime.

    The STA model is used for COM objects that are not thread safe. That means they do not handle their own synchronization. A common use of this is a UI component. So if another thread needs to interact with the object (such as pushing a button in a form) then the message is marshalled onto the STA thread. The windows forms message pumping system is an example of this.

    If the COM object can handle its own synchronization then the MTA model can be used where multiple threads are allowed to interact with the object without marshalled calls.

    There s a very good and crisp article by Larry Osterman, below is the link:


    Hope this helps..



    Whenever you see a reply and if you think is helpful, click "Alternate TextVote As Helpful"! And whenever you see a reply being an answer to the question of the thread, click "Alternate TextMark As Answer".

    Friday, February 8, 2013 11:51 AM