public class Depository { int capability = 5; private static LinkedList<Product> pool = new LinkedList(); public LinkedList getPool() { return pool; } public synchronized int getSize() { return pool.size(); } public synchronized boolean isEmpty() { return pool.isEmpty(); } public synchronized boolean isFull() { if (this.getSize() == this.capability) { return true; } else { return false; } } public synchronized void addLast(Product p) { this.notifyAll(); if (!this.isFull()) { pool.addFirst(p); //System.out.println("当前线程的名称:" + Thread.currentThread().getName()); System.out.println(Thread.currentThread().getName() + " 放入一个产品"); System.out.println("仓库已经有 " + this.getSize() + " 个了