计算密集型的程序使用多线程可以提高性能吗?C++
PHP中文网
PHP中文网 2017-04-17 13:17:09
0
2
805

没有大量的IO操作,主要是占用CPU,单核多核情况都有。C++11 thread
描述的不太清楚,其实想问的是如果我创建多个线程,这些线程的分配是怎样的?

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
阿神

Isn’t multi-threading used to handle high concurrency? This will increase the processing speed, otherwise single-threaded processing will last for many years and months

大家讲道理

Cluster and pipeline modes.
Cluster mode is suitable for tasks that are difficult to split, but there is no correlation between tasks, such as zip files, and there is no correlation between multiple files, then I can open four or five Threads zip different files.
Pipeline mode is suitable for those tasks whose sequence can be split. It extracts time-consuming operations and processes them with threads. Using the example of the zip file, one thread is used to control the zip task. Distribution, multiple threads go to zip, and after the zip is completed, it is handed over to another thread. This complete task is split into three stages. This mode is pipeline.

Your business needs to flexibly use these two basic design patterns

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template