SurfaceHolder the holder=this. GetHolder ();
Canvas, Canvas=holder. LockCanvas ();
Problem comes, if I were running directly, then the canvas is not available, always returns null, and if debug mode, and also is the new threads run in class B () method of the entrance position under a breakpoint, interrupt code to run to here and then click continue to run, so the two lines of code is working properly, can always get the correct canvas,
It was amazing, the same code, debug mode to work, instead of the normal operating mode error, the sense that gives a person is code must be on the run () method in hang, can obtain canvas, is really a mystery ~ ~ ~
CodePudding user response:
Test just now, proved my idea, namely the run () method must pause to normal operation.I was in the run () adds a line: Thread. Sleep (320), everything was normal, & lt; 310. There is so anal.
Do not know to have Daniel can explain the mystery.
CodePudding user response:
You wait for A running again after created BCodePudding user response:
You have never thought, you complete the canvas is not initialized, began to try to get it?