I have to wait in main thread for termination of working threads, then (on some event) I start those threads and wait for termination again, etc.
Calling join()
works well, but I want to do it faster.
Phaser looks like what I'm searching for, but I'm doing something wrong:
//*** application start ***
//create "empty" Phaser
//*** main thread ***
//event occured - start working threads
phaser.register();
//start working threads...
phaser.arriveAndAwaitAdvance(); //add arriveAndDeregister()?
// *** working thread start ***
phaser.register();
// do sth ...
// *** working thread end ***
phaser.arrive(); // replace with arriveAndDeregister()?