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.
posted on 2007-06-29 16:50 lqx 閱讀(244) 評(píng)論(0) 編輯 收藏