-
October 7th, 2013, 06:02 PM
#1
synchronized in a thread
Hello,
in the following code
Code:
public void run() {
while (run) {
Canvas c = null;
try {
c = sh.lockCanvas(null);
synchronized (sh) {
doDraw(c);
}
} finally {
if (c != null) {
sh.unlockCanvasAndPost(c);
}
}
}
}
I understand that the doDraw method should be done exclusively by my thread and not be interfered by some other thread. What I don't understand is why I have to provide a parameter (here sh which is a class variable), especially a parameter which doesn't seem to be used in the part which needs to be synchronized.
thanks, J.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|