Process vs Threads

前端 未结 6 435
余生分开走
余生分开走 2021-01-31 18:21

How to decide whether to use threads or create separate process altogether in your application to achieve parallelism.

6条回答
  •  無奈伤痛
    2021-01-31 18:41

    In Windows, processes are heavier to create then threads. So if you have several smaller tasks a thread or thread pool would be better. Or use a process pool to recycle the processes. Also sharing state between processes is more work then sharing state between threads. But then again: Threads could destabilize a complete process taking other threads down with it. If you want to minimize the chance of that happening you could go for separate processes. .Net's AppDomains might be a middle ground between both.

提交回复
热议问题