Process vs Threads

前端 未结 6 392
余生分开走
余生分开走 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:57

    Threads are more light weight, and for the making several "workers" just to utilize all availabe CPUs or cores, you're better of with threads.

    When you need the workers to be better isolated and more robust, like with most servers, go with sockets. When one thread crashes badly, it usually takes down the entire process, including other threads working in that process. If a process turns sour and dies, it doesn't touch any other process, so they can happily go on with their bussiness as if nothing happened.

提交回复
热议问题