how to debug the code which is hang [closed]
I have a multithreaded code which is hang in some case. I want to know what's the recommended way to debug?
When it hangs, you can attach the debugger and inspect thread state, including callstacks, to your heart's content. Often there will be one (or more) thread(s) that is (are) in a wait state, and you might be able to work out why that is.
If the state is not self-explanatory at the time of the hang, you can resort to techniques suggested to provide context information for the preceding program flow.
Because it is multi-threaded, you can't debug such as setting breakpoints, trace the statements and pause to see the values of the variables. The only way in my opinion is to print to the console and see the status from there.
精彩评论