Synchronized block is more preferred way because it doesn’t lock the calling object.
Synchronized methods locks the Object , on which the method is called.
It stops the execution and put them in wait state to get the lock on Object.
It may lead to poor responsiveness.
No comments:
Post a Comment
Note: only a member of this blog may post a comment.