-
Enhancement
-
Resolution: Unresolved
-
P3
-
None
-
5.0
-
Cause Known
-
x86
-
linux
A DESCRIPTION OF THE REQUEST :
A break() method would break the barrier, so all current and future waiters will get a BrokenBarrierException.
JUSTIFICATION :
In the code I'm working on, there is a situation where a barrier has been created, and code in other threads has been set in motion to cross a CyclicBarrer. The time comes when it's too late for them to be allowed to go ahead and use the barrier, so the code in the main thread wants to put the barrier into a broken state to prevent them from successfully crossing the barrier. There is currently no way to do that.
CUSTOMER SUBMITTED WORKAROUND :
I marked "Difficult to make even minimal progress" in the absence of a choice like "It is impossible for me to make my code completely robust with out this fix".
The submitter adds:
"The method name can't be break(), of course (D'Oh!). I probably should have said cancel().
And this proposed method should return the number of exceptions thrown or a Collection of the affected threads, so you can tell if you caused any BrokenBarrierExceptions to be thrown."
An anonymous SDN commenter adds:
"In a similar vein, i'm working with a CyclicBarrier where some of the participating threads may encounter an exception. when that happens, i'd like all the threads to bailout. however, there's no way for the failed thread to signal that status reliably. i would like a method like this that could be put in a finally block at the end of the thread code so that the other threads do not hang waiting for the failed thread.""
A break() method would break the barrier, so all current and future waiters will get a BrokenBarrierException.
JUSTIFICATION :
In the code I'm working on, there is a situation where a barrier has been created, and code in other threads has been set in motion to cross a CyclicBarrer. The time comes when it's too late for them to be allowed to go ahead and use the barrier, so the code in the main thread wants to put the barrier into a broken state to prevent them from successfully crossing the barrier. There is currently no way to do that.
CUSTOMER SUBMITTED WORKAROUND :
I marked "Difficult to make even minimal progress" in the absence of a choice like "It is impossible for me to make my code completely robust with out this fix".
The submitter adds:
"The method name can't be break(), of course (D'Oh!). I probably should have said cancel().
And this proposed method should return the number of exceptions thrown or a Collection of the affected threads, so you can tell if you caused any BrokenBarrierExceptions to be thrown."
An anonymous SDN commenter adds:
"In a similar vein, i'm working with a CyclicBarrier where some of the participating threads may encounter an exception. when that happens, i'd like all the threads to bailout. however, there's no way for the failed thread to signal that status reliably. i would like a method like this that could be put in a finally block at the end of the thread code so that the other threads do not hang waiting for the failed thread.""
- links to
-
Review(master) openjdk/jdk/25880