I have found some hint: when I take SocketReceiver code, create my class based on that code with only one single difference - instead using logbacks common ScheduledThreadPoolExecutor I provide one in every Receiver instance (instead of
getContext().getScheduledExecutorService().submit(connector)
I use:
this.executor.submit(connector);
Everything starts working just fine... My conclusions is that there is something wrong with ScheduledThreadPoolExecutor and it only uses 2 threads (it is initialised like this in ExecutorServiceUtil:
public static ScheduledExecutorService newScheduledExecutorService() {
return new ScheduledThreadPoolExecutor(2, THREAD_FACTORY);
}
) and when both are busy with logbacks core and single receiver - nothing else works just hanging and waiting for free executor thread which is never available... I think it shoud detect starwation like this and fire another thread (by default ther is max of Integer.MAX_VALUE after all...)
anyway - I cannot think of any global solution for now. I will stay with my own receiver with own thread. But I think it might cause other problems in future.
|