如果很多线程从一个数据结构读取数据而很少线程修改其中数据的话,可以使用java.util.concurrent.locks.ReentrantReadWriteLock。在这种情况下,允许对读者线程共享访问是合适的。当然,写者线程依然必须是互斥访问的。 public class ReentrantReadWriteLockTest { //构造一个ReentrantReadWriteLock对象 private static ReentrantReadWriteLock rwl = new ReentrantReadWriteLock(); //读锁 private Lock readLock = rwl.readLock(); //写锁 private Lock writeLock = rwl.writeLock(); public static void main(String[] args) { } public double getTotalBalance(){ readLock.lock(); try { ... }finally { readLock.unlock(); } } public void transfer(...){ writeLock.lock(); try{...} finally { writeLock.unlock(); } } }