@@ -0,0 +1,1302 @@
+package ru.agolovin;%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%0Aclass Counter %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        Counter problem = new Counter();%0A        Thread thread = new Thread(() -%3E %7B%0A            while (!problem.stop()) %7B%0A                anInt++;%0A            %7D%0A        %7D);%0A        Thread thread2 = new Thread(() -%3E %7B%0A            while (!problem.stop()) %7B%0A                anInt++;%0A            %7D%0A        %7D);%0A        thread.start();%0A        thread2.start();%0A        try %7B%0A            Thread.sleep(1000);%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%7D%0A

add task1 in part2 chapter7 package2