R
raphfrk
Is there a recommended way of "chaining" interrupted exceptions?
This is to implement a method call that doesn't throw an interrupted exception, but which calls a method which can be interrupted.
public void uninterruptableWait(Object c) {
boolean done = false;
boolean interrupted = false;
synchronized (c) {
while (!done) {
try {
c.wait();
done = true;
} catch (InterrupedException ie) {
interrupted = true;
}
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
}
If that interrupt was unexpected, and causes a stack trace, then it would be nice if it could include the details from the thrown exception.
Is there a better way to do the above?
This is to implement a method call that doesn't throw an interrupted exception, but which calls a method which can be interrupted.
public void uninterruptableWait(Object c) {
boolean done = false;
boolean interrupted = false;
synchronized (c) {
while (!done) {
try {
c.wait();
done = true;
} catch (InterrupedException ie) {
interrupted = true;
}
}
}
if (interrupted) {
Thread.currentThread().interrupt();
}
}
If that interrupt was unexpected, and causes a stack trace, then it would be nice if it could include the details from the thrown exception.
Is there a better way to do the above?