/////////////////////////////////////////////////////////// Test.Java 测试代码
public class Test1 {
/**
     * @param args
     */
    public static void main(String[] args) {
//如有多出生产此处q必须为单例模式,如最后那个源文件!
        QueueThread q = new QueueThread();
        // 启动10条消费线程
        for (int i = 0; i < 5; i++) {
            Consumer c = new Consumer(q);
            c.start();
        }
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        // for (int i = 0; i < 50; i++) {
Producer p = new Producer(q);
        p.setStr("生产线程产生ggggggggg  ");
        p.start();
        // }
        // 非生产线程产生数据
        for (int i = 0; i < 50; i++) {
q.put(" 非生产线程产生数据  " + i);
        }
}
}
/////////////////////////////////////////// QueueThread.java 线程池
public class QueueThread {
final static int MaxLength = 10;// 等待队列大小
private static LinkedList thread_pool = null;
public QueueThread() {
        synchronized (this) {
            if (thread_pool == null) {
                System.out.println("初始化");
                thread_pool = new LinkedList();
            }
        }
    }
/**
     * 判断是否已满
     * 
     * @return
     */
    public boolean isFull() {
return thread_pool.size() >= MaxLength ? true : false;
}
/**
     * 判断是否为空
     * 
     * @return
     */
    public boolean isEmpty() {
return thread_pool.isEmpty();
}
/**
     * 生产模式:插入数据到队列
     * 
     * @param obj
     */
    public synchronized void put(Object obj) {
        while (isFull()) {
            try {
                System.out.println("满了等待。。。。。。");
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        // 如果没满,插入
        // 插入到队尾
        System.out.println("没满。。。。。");
        thread_pool.addLast(obj);
        notify();// notifyAll();?
    }
/**
     * 消费模式:从队列里面取出一个对象
     * 
     * @return
     */
    public synchronized Object get() {
        // 如果是空的则等待
        while (isEmpty()) {
            System.out.println("没数据等待。。。。。");
            try {
                wait();
            } catch (InterruptedException e) {
