不知这样行吗private final ReentrantLock lock = new ReentrantLock();public void work() { if(!lock.tryLock()) return;try{for(int i=0;i<1000;i++) { System.out.println(Thread.currentThread().getId()); } } }finally{ lock.unlock();}