In his famous concurrency book , Goetz suggests that the optimal number of threads in a pool can be calculated using
N threads = N CPU * U CPU * (1 + W/C)
W/C is the ratio of expectation to calculation. I want to develop a custom Executor that will adjust the number of worker threads using ThreadPoolExecutor.setCorePoolSize() , but I don't know how to calculate the WC ratio. Assuming this ThreadPool is the only one used by my application, how can I calculate this ratio?
Is there a way to track how much time a workflow spends waiting / sleeping? Or is there an implementation for this problem?
source share