It is usually a bad idea for threads in the pool to block while waiting for other threads in the same thread pool.
I would try to change the design to non-blocking. If a thread needs the result of another operation processed by the same executor, I would ask that the executor return the task after the completion of the second operation. Or put the object in the queue that needs to be picked up later when another task ends.
Alternatively, you can do what Swing does with modal dialogs, and have a thread that is going to block the start of the child thread to handle requests until the parent thread is blocked. This is difficult to do correctly, and you will need to manually manage streams that are much less secure than using the Contractor.
source share