比如:
public class CountThread implements Runnable {
private CountWorker countWorker;
public CountThread(CountWorker countWorker) {
this.countWorker = countWorker;
}
public void run() {
System.out.println( Thread.currentThread().getName() + " get sum is : " + countWorker.sum);
countWorker.sum++;
}
}
System.out的sum和执行sum++时的sum是打印时去主存获取一次然后sum++时去主存再获取一次吗?