lqxue

常用链接

统计

book

tools

最新评论

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 阅读(233) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: