For diagnostic purposes I sometimes need to store the call stack that lead to a given state transition (such as granting a lock, committing a transaction, etc.) so that when
I think you can get the same thing with:
StackTraceElement[] cause = Thread.currentThread().getStackTrace();