Reputation: 1154
I am having a list of requests in database. My application has to take the requests from DB and execute it in a thread. Only four threads can run at a time. Application should not process any requests before 9 AM and after 7 PM.
Could you please suggest the best way to implement this in java? Is Spring ThreadPoolTaskExecutor a good option?
Upvotes: 2
Views: 106
Reputation: 21883
Only four threads can run at a time
For this you can use a Fixed Thread Pool Executor
Application should not process any requests before 9 AM and after 7 PM.
for this you must use a Cron Trigger in Spring Task Executor. Follow this post
You should have totally 5 threads. One will be invoked by the Spring Task Executor when the Cron is Triggered and That thread should have a Fixed Thread Pool Executor which must spawn Child Threads. In this case maximum of 4.
Upvotes: 1