package ru.agolovin;

/**
 * @author agolovin (agolovin@list.ru)
 * @version $Id$
 * @since 0.1
 */

public class ProducerCustomer {

}

@@ -19,118 +19,1103 @@
 n;%0A%0A
-/**%0A * @author agolovin (agolovin@list.ru)%0A * @version $Id$%0A * @since 0.1%0A */%0A%0Apublic class ProducerCustomer %7B
+import java.util.Queue;%0Aimport java.util.concurrent.LinkedBlockingQueue;%0A%0Aimport static java.lang.Thread.sleep;%0A%0A/**%0A * @author agolovin (agolovin@list.ru)%0A * @version $Id$%0A * @since 0.1%0A */%0A%0Apublic class ProducerCustomer %7B%0A%0A    private int quant = 5;%0A%0A    private boolean flag = false;%0A%0A    private Queue%3CInteger%3E queue = new LinkedBlockingQueue%3C%3E();%0A%0A    public void init() %7B%0A%0A    %7D%0A%0A    private Thread producer() %7B%0A        Thread thread = new Thread(() -%3E %7B%0A            for (int i = 0; i %3C quant; i++) %7B%0A                synchronized (queue) %7B%0A                    queue.add(i++);%0A                    queue.notify();%0A                    System.out.println(String.format(%0A                            %22Thread %25s added %25s%22, Thread.currentThread().getId(), i));%0A                %7D%0A                if ( i == (quant - 1)) %7B%0A                    flag = true;%0A                %7D%0A                try %7B%0A                    Thread.sleep(10);%0A%0A                %7D catch (InterruptedException e) %7B%0A                    e.printStackTrace();%0A                %7D%0A            %7D%0A        %7D);%0A        return thread;%0A    %7D%0A
 %0A%0A%7D%0A

add task1 in part4 chapter7 package2