I am new to concurrent program, while reading about CyclicBarrier i have one doubt, that is what happens if an exception is thrown by barrier action (an action supplied to CyclicBarrier to run after reaching the barrier).
The barrier action is defined by a Runnable, which cannot throw a checked exception. It seems reasonable to expect that any unchecked exceptions must be ignored; they surely don't want to be allowed to kill the barrier's management thread
In other words, make sure you add any unchecked exception management code to your action Runnable.
Thanks for your quick reply. but i want to know if we dont write the exceprion management code in barrier action then what will happen to barrier threads.
i mean that do barrier threads continue their execution or throw the BrokenBarrierException?
The thread that happens to execute the barrier action (which is one of the threads that awaits, but I don't believe it's predictable as to which) receives the unhandled exception, the others get a BrokenBarrier.
Why would you not just handle the exception in the barrier action code?