Is the MATLAB COM Automation Server thread safe?
Show older comments
Matlab Engine is not thread safe. Is this also true for the MATLAB COM Automation Server when using ProgID = Matlab.Application?
Answers (1)
Guillaume
on 11 Feb 2016
1 vote
Generally speaking, COM is responsible for managing communication between threads. If your program is multithreaded and you're talking to a single threaded server. COM marshalls the data between the two and takes care of thread safety. See MSDN for more details. So yes, matlab through COM should be thread safe because COM is.
However, if you use the Matlab.Application progid, and you instantiate a new server in different threads, all these threads share the same matlab instance. So, within matlab if you manipulate globals or the workspace, changes in one thread will be visible in the other. It's still done safely due to COM marshalling.
You can also use the Matlab.Application.Single to have a dedicated matlab instance per COM instance. See the doc
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!