I am trying to simplify the task as follows:
- I have about 100 files that I would like to read and then process the data.
- Why do I maintain an array of file names and locations
- I create streams to read files.
Now my problem is that I would like to make sure that only 5 threads appear at a time, since starting 100+ threads is not a good idea at all.
So, please tell me which approach should I use to ensure that only 5 threads work on time, and as soon as one of them is completed, a new one can be launched.
Thanks everyone
source
share