2
id = 1-id是原子吗?
在OCP Java SE 6程序员实践考试的第291页中,问题25: public class Stone implements Runnable { static int id = 1; public void run() { id = 1 - id; if (id == 0) pick(); else release(); } private static synchronized void pick() { System.out.print("P "); System.out.print("Q "); } private synchronized void release() { System.out.print("R "); …