What to do, if debug behaviour differs from normal execution?
Two solutions:
a) Use poor man's debugger (print to the console) or use a logging framework. After the error happens, analyze the output.
b) Write a test case that tries to reproduce the problem. Even if you can't find it that way, this will clean your code and sometimes solve the issue.
It's really difficult to debug multi threaded applications.
You can try to debug using the old System.out.println technic instead of using the debugger ... may be this will allow you to debug while having the different behavior you mentioned.
Manu
You might observe a race-condition that only occurs when there are no debug statements that slow down execution. It could be helpful to start with reviewing your threading model and to watch out for any possible locks.
I tried to check my assumption I did and check them once more.
Excessive logging could be helpful in some situations, but not always. In my case, it didn't help that much.
With logging you can see, where your assumptions are correct and which of them fail.
My personal solution was Java specific. The Java ClassLoader does not load classes completely since JDK 1.5. In a debug session, it has to be loaded completely. So some variables were not initialized well and the output differed from the normal run.
That reason is very hard to find.