@@ -0,0 +1,1332 @@
+package methods_objects;%0A%0A/**%0A * @author SergeyI%0A * @since 01.11.2017%0A *%0A * Here this is class show us how are working two threads in one queue.%0A */%0Apublic class ProducerCustomer%3CE%3E %7B%0A    Node%3CE%3E node = new Node%3C%3E();%0A    Object lock = new Object();%0A%0A    public void add(E o) %7B%0A        synchronized (lock) %7B%0A            if (node == null) %7B%0A                node = new Node%3CE%3E(o);%0A            %7D else if (node.next == null) %7B%0A                node.next = new Node(o);%0A%0A            %7D else %7B%0A                Node%3CE%3E temp = node;%0A                node = node.next;%0A                add(o);%0A                node = temp;%0A            %7D%0A                lock.notify();%0A        %7D%0A    %7D%0A%0A    public E get() %7B%0A        Node%3CE%3E temp;%0A        synchronized (lock) %7B%0A            temp = new Node%3C%3E();%0A            if (node != null) %7B%0A                temp = node;%0A                node = node.next;%0A            %7D else %7B%0A                System.out.println(%22any%22);%0A                try %7B%0A                    lock.wait();%0A                %7D catch (InterruptedException e) %7B%0A                    e.printStackTrace();%0A                %7D%0A            %7D%0A        %7D%0A        return temp.object;%0A    %7D%0A%0A    private class Node%3CE%3E %7B%0A        Node next;%0A        E object;%0A%0A        public Node(E e) %7B%0A            object = e;%0A        %7D%0A%0A        public Node() %7B%0A        %7D%0A    %7D%0A%0A%0A%7D%0A

task 1098