Relates :
|
AbstractQueuedSynchronizer and AbstractQueuedLongSynchronizer handle exceptions during acquire like this try { ... } catch (RuntimeException e) { handle(); throw e; } This fails to handle errors or other pathological throwables (e.g. a checked Exception can always be thrown using Thread.stop(Throwable)) More robust and clear is to use the idiom boolean failed = true; try { ... ; failed = false; } finally { if (failed) handle(); }
|