Resources
Debug Java Race Conditions with Reverse Debugging in IntelliJ IDEA
Race conditions are the ones that eat a whole week. The thread that caused the problem is long gone by the time you see the exception, and the moment you attach a debugger the failure stops happening.
You cannot chase a Heisenbug. But you can record it once and then work backwards from the failure.
This tutorial walks through a ConcurrentModificationException inside IntelliJ IDEA, starting at the moment the exception is thrown and stepping back through the execution history to the exact line in a background thread that modified the shared list. Exception breakpoints, field watchpoints, and reverse execution, showing you what the program did rather than what the code says.