I have created priority based threads ex-
Thread Priority
- T1 P1
- T2 P1
- T3 P2
- T4 P2
I am using java.util.concurrent.CountDownLatch
for all threads with same priority to execute simultaneously first then proceed with the next priority threads likewise . Sometimes my application hangs, on seeing the thread dump I am observing all threads are in either Runnable or Parking state. I have handled all the corner cases to do count down of the latch so that next priority threads execute.
Is it possible that the JVM kills the thread with P1 in between the execution so count down of latch does not happen, and the P2 priority threads never execute?