(
(
(
(
(
(
(
(
(
注意原子型操作只限於第
double 和long 變量是非原子型的(non
class xxx extends Thread{
//i會被經常修改
private int i;
public synchronized int read(){ return i;}
public synchronized void update(){ i = i +
}
[
From:http://tw.wingwit.com/Article/program/Java/gj/201311/27707.html