I have a java application that sends requests to the server and returns me the response. The requests are run on separate threads each.
What I want to do is maintain 5 threads at a time (hence, 5 requests going at a time). Also, if a thread finishes, I want to start a new thread so that 5 threads are running at all times.
Initially I thought I could use join when calling the thread, but realized that will block my main thread.
Is there a way to get this done? I haven’t programmed in Java much and am open to any suggestions/advice.
I would use an ExecutorService
This will perform up to 5 tasks at once.