@@ -0,0 +1,2155 @@
+package ru.agolovin;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Iterator;%0Aimport java.util.NoSuchElementException;%0A%0A/**%0A * @author agolovin (agolovin@list.ru)%0A * @version $Id$%0A * @since 0.1%0A * @param %3CT%3E Generic%0A */%0A%0Apublic class ThreadSafeArrayList%3CT%3E %7B%0A    /**%0A     * Array capacity.%0A     */%0A    private static final int DEFAULT_CAPACITY = 100;%0A%0A    /**%0A     * Array.%0A     */%0A    private Object%5B%5D array;%0A%0A    /**%0A     * Last index in array.%0A     */%0A    private int index;%0A%0A    /**%0A     * Constructor.%0A     */%0A    public ThreadSafeArrayList() %7B%0A        this.array = new Object%5BDEFAULT_CAPACITY%5D;%0A    %7D%0A%0A    /**%0A     * Constructor. Custom array size.%0A     *%0A     * @param size int%0A     */%0A    public ThreadSafeArrayList(int size) %7B%0A        this.array = new Object%5Bsize%5D;%0A    %7D%0A%0A    /**%0A     * Rise array capacity.%0A     */%0A    private void riseArray() %7B%0A        this.array = Arrays.copyOf(this.array, this.index + 10);%0A    %7D%0A%0A    /**%0A     * Iterator.%0A     * @return T object%0A     */%0A    public synchronized Iterator%3CT%3E iterator() %7B%0A        return new Iterator%3CT%3E() %7B%0A            private int current = 0;%0A%0A            @Override%0A            public boolean hasNext() %7B%0A                return current != index;%0A            %7D%0A%0A            @Override%0A            public T next() %7B%0A                if (hasNext()) %7B%0A                    return (T) array%5Bcurrent++%5D;%0A                %7D else %7B%0A                    throw new IndexOutOfBoundsException();%0A                %7D%0A            %7D%0A        %7D;%0A    %7D%0A%0A    /**%0A     * Add element to array.%0A     *%0A     * @param e Object%0A     */%0A    public synchronized void add(Object e) %7B%0A        if (this.array.length %3E index) %7B%0A            this.array%5Bindex++%5D = e;%0A        %7D else %7B%0A            riseArray();%0A            this.array%5Bindex++%5D = e;%0A        %7D%0A%0A    %7D%0A%0A    /**%0A     * Get element from array.%0A     *%0A     * @param index int%0A     * @return Element Object%0A     */%0A    public synchronized T get(int index) %7B%0A        Object result;%0A        if (index %3C this.index && index %3E= 0) %7B%0A            result = this.array%5Bindex%5D;%0A        %7D else %7B%0A            throw new NoSuchElementException();%0A        %7D%0A        return (T) result;%0A    %7D%0A%7D

add task3 in part3 chapter7 package2