AtomicBoolean started = new AtomicBoolean(false) if(started.compareAndSet(false, true)){ //todo something }
采用原子操作