What i need is a tool/class that acts like CoundDownLatch but can be counted up and down. Whenever a task is executed it will counted up, when a task is done it is counted down. There can be multiple tasks running parallel, and one thread should wait until no task is executing/ the counter is at 0.
I looked into the Phaser class, but i don't know if it provides what i am looking for, maybe it can be used to solve this puzzle?