Reputation: 491
If I always call a method from a synchronised block then what is advantage of making any method as synchronized?
Thanks in advance.
Upvotes: 0
Views: 18
Reputation: 18302
It's just another way of writing the same thing. If your synchronized
block exactly matches a method block, then it's just easier to read that way. Syntax sugar.
Which is easier?
public synchronized void myMethod() {
// do stuff
}
public void myMethod() {
synchronized(this) {
// do stuff
}
}
Upvotes: 1