I have a question that is related to possible overhead of ExecutorService
s in Java.
The present implementation has ExecutorService A
with a capacity of 5 threads.
A
.A
threads do some database reading and writing.Now, a thread of type B
will run after some threads of type A
has finished.
B
threads that will run is different from time to time.B
threads do some filesystem IO (not database).So should I
ExecutorService
to handle type B
threadsExecutorService A
and run type B
threads with that one as well?I'm thinking that there might be some extra overhead for Java to have two ExecutorService
s, but on the other hand the total number of threads will increase either way. Does it matter at all?
I will recommend two ExecutorServices
, then you can take advantage of the different ExecutorService
s provided by the java.util.concurrent
package.
It makes the code easier and the overhead is ignorable.
ExecutorService
a with a fixed thread pool set to five threads.ExecutorService
b with a cached thread pool.