ReentrantLock ReentrantLock fairLock = new ReentrantLock(true);// 这里是演示创建公平锁,一般情况不需要。 fairLock.lock(); try {// do something } finally {fairLock.unlock(); }