difference between Synchronized method and Synchronized block
Synchronized method - By using this, the method will be thread safe. But if your method access any non-thread safe objects, you may have concurrency problem.Synchronized block - To complement what Synchronized method cannot do. If you do:
synchronized (nonThreadSafeObject) {
// accessing nonThreadSafeObject here
}
Then the object will become thread safe.