Hello! I'v been coming to drawing graphics in Android. There's a lot of sample applications out there, but one thing I always seeing is lockCanvas. Can someone explain it closer since I really don't get it and also because im think it's important to understand to future programming?
An example:
try {
c = panel_thread.getHolder().lockCanvas(null);
synchronized (panel_thread.getHolder()) {
panel_thread.update();
panel_thread.onDraw(c);
}
}
This is what I have for now. How should I interpret this correct? What does synchronized do? Why is it important to assign the canvas-object into a getHolder and lockCanvas?
This part is also confusing:
panel_thread.getHolder().unlockCanvasAndPost(c);
Why is this necessary? I really need a closer explanation. :)
Thanks!