I have a task which might last up to 100ms that I want to kick off at the start of handling a request and grab the result when I need it later on. I don't want to block and extend every request by this amount.
In a vanilla Java app I'd create a ExecutorService
and run it as a Callable<T>
using the Future<T>
to get the result later on.
Since Tomcat maintains its own pool of threads, should I be trying to coordinate with it? In other words, is my ExecutorService pool competing with Tomcat's threads? Is this an issue? Is there an advantage to piggybacking onto Tomcat's pool somehow?
Any advice from someone who has similar experience would be much appreciated. Also I'm not interested at this point in adding additional dependencies like Spring, etc.