@@ -0,0 +1,1547 @@
+package ru.agolovin;%0A%0Aimport net.jcip.annotations.GuardedBy;%0Aimport net.jcip.annotations.ThreadSafe;%0A%0Aimport java.util.concurrent.atomic.AtomicInteger;%0A%0A/**%0A * @author agolovin (agolovin@list.ru)%0A * @version $Id$%0A * @since 0.1%0A */%0A%0A@ThreadSafe%0Aclass Count %7B%0A%0A    /**%0A     * Expected result.%0A     */%0A    private static final int LIMIT = 100_000_000;%0A%0A    /**%0A     * Count.%0A     */%0A    private static int anInt = 0;%0A%0A    /**%0A     * Count hits.%0A     */%0A    private AtomicInteger lim = new AtomicInteger();%0A%0A    /**%0A     * Main method.%0A     *%0A     * @param args String%5B%5D%0A     */%0A    public static void main(String%5B%5D args) %7B%0A        Count count = new Count();%0A        Thread thread = new Thread(() -%3E %7B%0A            while (!count.stop()) %7B%0A                count.increment();%0A            %7D%0A        %7D);%0A        Thread thread2 = new Thread(() -%3E %7B%0A            while (!count.stop()) %7B%0A                count.increment();%0A            %7D%0A%0A        %7D);%0A        thread.start();%0A        thread2.start();%0A        try %7B%0A            thread.join();%0A            thread2.join();%0A        %7D catch (InterruptedException e) %7B%0A            e.printStackTrace();%0A        %7D%0A        System.out.println(String.format(%22Expected %25s%22, LIMIT));%0A        System.out.println(String.format(%22Result %25s%22, anInt));%0A    %7D%0A%0A    /**%0A     * Stop.%0A     *%0A     * @return boolean result%0A     */%0A    private boolean stop() %7B%0A        return lim.incrementAndGet() %3E LIMIT;%0A    %7D%0A%0A    @GuardedBy(%22this%22)%0A    private void increment() %7B%0A        synchronized (this) %7B%0A            anInt++;%0A        %7D%0A    %7D%0A%7D%0A

add task1 in part3 chapter7 package2