How to properly limit net4j's thread pool [message #1795103] |
Fri, 14 September 2018 10:50  |
Eclipse User |
|
|
|
Hi,
In a real-world net4j/cdo application, we see occasional thread-spikes. While the application typically runs well below <150 threads total, sometimes we see spikes up to ~2000 threads - which is already a bit concerning, keeping in mind the spikes seem random.
I found out those threads are created by net4j, however when looking at the thread-dump they are already lurking in the ThreadPool, just to be released soon after.
To limit those spikes, this is what I currently do during setup:
ExecutorService o = ExecutorServiceFactory.get(container);
try {
Method coreMethod = ThreadPoolExecutor.class.getMethod("setCorePoolSize", new Class[] { int.class});
Method maxMethod = ThreadPoolExecutor.class.getMethod("setMaximumPoolSize", new Class[] { int.class});
Proxy.getInvocationHandler(o).invoke(o, coreMethod, new Object[] {1});
Proxy.getInvocationHandler(o).invoke(o, maxMethod, new Object[] {2});
} catch (Throwable thrbl) {
throw new RuntimeException(thrbl);
}
Therefore my question:
* Is it harmful to limit net4j's ThreadPool to a certain size?
* Is there a proper way, instead of using ugly reflection trickeria?
Thank you in advance
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06601 seconds