There is a collection of files in the file system on the server. When an incoming request is necessary to read all these files and carry out actions with the data. Is it possible to do this asynchronously? Ie at the output you need a collection of results for each file.
The correct way is to apply the
Producer-Consumerscheme with a single reading thread and a pool of working threads that will perform operations on files.
That is, roughly speaking, the reading thread adds some task, which is picked up by
worker thread'ами, and
WaitForAll,is done for all tasks until the final result is obtained.
The only reading thread makes sense on the assumption that parallel reading is an order of magnitude worse than synchronous reading.
- You can start exploring with the