由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - 这个Method为什么需要同步?
相关主题
发现 synchronized 的一个问题synchronization for counters
同一个Lock锁两次,性能比较差synchronization 锁住了什么?
问一个基础问题新手问个multi-threading关于synchronized和volatile的问题
请教:怎么把synchronize的method改成用thread 但thread safe呢?Talk a little more about How to lock a file
synchronized method does lock the object that passed into the method as a parameter?请教一个多线程lock机制的问题
multi-threading guru们 (转载)怎么synchronize时间捏
CC150 16.6答案是不是有问题? (转载)HashMap cache
Java synchronized method一问Apply lock on a class.
相关话题的讨论汇总
话题: getcount话题: count话题: method话题: public
进入Java版参与讨论
1 (共1页)
u*l
发帖数: 1943
1
public class Students {
private int count;
public synchronized int getCount(){
return count;
}
}
感觉getCount()只是返回一个属性值,不需要lock保护啊。
z****e
发帖数: 54598
2
setCount的那个方法也有synchronized吧
r*****l
发帖数: 2859
3
Methods that set the count should be sync-ed too. Cannot you see the code?

【在 z****e 的大作中提到】
: setCount的那个方法也有synchronized吧
r*****l
发帖数: 2859
4
Oops, re-ed to wrong person :)

【在 r*****l 的大作中提到】
: Methods that set the count should be sync-ed too. Cannot you see the code?
1 (共1页)
进入Java版参与讨论
相关主题
Apply lock on a class.synchronized method does lock the object that passed into the method as a parameter?
请教:performance issuemulti-threading guru们 (转载)
java的volatileCC150 16.6答案是不是有问题? (转载)
Java concurrency的疑惑,难道我理解错了? (转载)Java synchronized method一问
发现 synchronized 的一个问题synchronization for counters
同一个Lock锁两次,性能比较差synchronization 锁住了什么?
问一个基础问题新手问个multi-threading关于synchronized和volatile的问题
请教:怎么把synchronize的method改成用thread 但thread safe呢?Talk a little more about How to lock a file
相关话题的讨论汇总
话题: getcount话题: count话题: method话题: public