Is the MATLAB COM Automation Server thread safe?
显示 更早的评论
Matlab Engine is not thread safe. Is this also true for the MATLAB COM Automation Server when using ProgID = Matlab.Application?
回答(1 个)
Guillaume
2016-2-11
1 个投票
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
类别
在 帮助中心 和 File Exchange 中查找有关 Use COM Objects in MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!