@ThreadSafe public class ConcurrentCounter { @GuardedBy("this") private int count; public synchronized void increment() { count++; } public synchronized void decrement() { count--; } public synchronized int getCount() { return count; } } <dependency> <groupId>net.jcip</groupId> <artifactId>jcip-annotations</artifactId> <version>1.0</version> </dependency>


上一篇:
下一篇:
切换中文