一个multithread的小问题# JobHunting - 待字闺中
w*f
1 楼
PIE chapter 8 bank example:
public boolean deposit( double amount){
...
newBalance = userBalance + amount;
userBalance = newBalance;
...
有些困惑(maybe naive)
why not
userBalance +=amount;
对thread 安全有影响吗?
public boolean deposit( double amount){
...
newBalance = userBalance + amount;
userBalance = newBalance;
...
有些困惑(maybe naive)
why not
userBalance +=amount;
对thread 安全有影响吗?