Home  >  Q&A  >  body text

计算密集型的程序使用多线程可以提高性能吗?C++

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

PHP中文网PHP中文网2715 days ago737

reply all(2)I'll reply

  • 阿神

    阿神2017-04-17 13:19:09

    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

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:19:09

    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

    reply
    0
  • Cancelreply