I have a scenario in which I use streams.
Firstly, I have a folder where there are files that are updated frequently. So, I wrote a stream that reads the contents of the folder and writes the file names to a static list and updates the list if new files appear.
Secondly, I wrote another thread that takes the file names from the list and does some processing with the files.
These two threads work continuously, one checks for new files, processes new files.
Now I need to process three files simultaneously with three threads. When one thread completes processing, another thread takes a different file name from the list and starts the process.
So, I need some kind of mechanism to have three threads and check them, whether they are alive or not, and accordingly launches a new thread, and the list of files is also often updated.
I also looked ExecutorService, but while the list was updated, I could not provide an updated list.
Thanks Sandeep
source
share