解释一下下面两段代码的差别// 代码1public class Sample { private static int count = 0; synchronized public static void increment() { count++; }}// 代码2public class Sample { private static AtomicInteger count = new AtomicInteger(0); public static void increment() { count.getAndIncrement(); }}
|