<p>Is there a way to detect, from within the finally clause, that an exception is in the process of being thrown?</p>

<p>See the example below:</p>

<pre><code>
try {
    // code that may or may not throw an exception
} finally {
    SomeCleanupFunctionThatThrows();
    // if currently executing an exception, exit the program,
    // otherwise just let the exception thrown by the function
    // above propagate
}
</code></pre>

<p>or is ignoring one of the exceptions the only thing you can do?</p>

<p>In C++ it doesn't even let you ignore one of the exceptions and just calls terminate(). Most other languages use the same rules as java.</p>

No I do not believe so.  The catch block will run to completion before the finally block.
```
```
try {
    // code that may or may not throw an exception
} catch {
// catch block must exist.
finally {
    SomeCleanupFunctionThatThrows();
// this portion is ran after catch block finishes
}
```
```
Otherwise you can add a synchronize() object that the exception code will use, that you can check in the finally block, which would help you identify if in a seperate thread you are running an exception.