we use Java17 and Springboot 2.7.2.
So, debugging into a customer I saw that there are two thread pool worker threads (only two exist at this moment, seen by debugger) that both wait in the ForkJoinTask – forever.
Checking more, apparently we have multiple scheduled thread pool executors (Executors.newScheduledThreadPool
with core size 1 initialized…). Within these we do a call like:
myStuff.getEntries().parallelStream()
.forEach(entry -> doSomethingWithIt(entry.getId().toString(), resultMap, myStuff));
resultMap is the only field used for writing and it is a ConcurrentHashMap
, so should be fine (I hope).
Now I need a bit brain power / experience from you guys… Why can this create a deadlock / task exhaustion? I thought the core threads are just for stuff that is “reserved”/hold for some schedulers. parallelStream under the hood also tries to get some task runners, will it use them from the same internal pool or from where?
I don’t know how it works under the hood, any ideas/insights would be useful… I’ll probably just remove parallelStream for now, but why does it seem to get exhausted on tasks, how could I increase?