ExecutorCountUtil.java 627 B

1234567891011121314151617181920212223
  1. package com.kingdee.eas.custom.beisen.synchronouspos.handler;
  2. import java.util.concurrent.atomic.AtomicInteger;
  3. public class ExecutorCountUtil {
  4. private final AtomicInteger count = new AtomicInteger(0);
  5. public int get() {
  6. return count.get(); // 原子读取
  7. }
  8. private static ExecutorCountUtil examples = new ExecutorCountUtil();
  9. public void countPlusPlus() {
  10. count.incrementAndGet();
  11. }
  12. public void countLessLess() {
  13. count.decrementAndGet();
  14. }
  15. public static ExecutorCountUtil getExamples() {
  16. return examples;
  17. }
  18. private ExecutorCountUtil() {
  19. }
  20. }