Home > Back-end >  Please write a multi-threaded example
Please write a multi-threaded example

Time:09-23

According to handle the amount of data dynamically create several threads, each thread processing a set of data, processing methods, such as from each set of 20000 data to find maximum and minimum values, if there are 40000 is divided into two groups to create two threads, 60000 to create three threads, and so on, to create several threads require execution at the same time,

CodePudding user response:

Is the role of the thread, and other threads (including the main thread) the allocation of CPU time, common code execution,
In this way, you can use a thread to handle affairs, however, if you deal with the same data source, a number of thread processing, with a single thread processing, speed up the little,
Because, at this time a thread, and multiple threads processing, with the increase of your thread, allocation of CPU time, were small,

CodePudding user response:

I meant the first thread does not affect the other threads when processing work
  • Related