What is the difference between a synchronized function and synchronized block? [duplicate]
问题 This question already has answers here : What is the difference between a synchronized method and synchronized block in Java? [duplicate] (6 answers) Closed 2 years ago . what is the difference between public synchronized void addition() { //something; } and public void addtion() { synchronized (//something) { //something; } } If I am wrong Ignore this question. 回答1: it the first one only one thread can execute whole method at a time whereas in second one only one thread can execute that