@@ -0,0 +1,1232 @@
+package threads.practice;%0A%0Aimport net.jcip.annotations.GuardedBy;%0Aimport net.jcip.annotations.ThreadSafe;%0A%0A/**%0A * Created by Sergey on 12.10.2017.%0A *%0A * Class Counter counts numbers from two threads at once.%0A */%0A@ThreadSafe%0Apublic class Counter implements Runnable %7B%0A    /**%0A     * @count - is start value.%0A     */%0A    @GuardedBy(%22this%22)%0A    long count = 0;%0A%0A    /**%0A     * method run - he calls method increment() and show us new value on console.%0A     */%0A    @Override%0A    public void run() %7B%0A        increment(this);%0A        System.out.println(count);%0A    %7D%0A%0A    /**%0A     * method increment - accept exemplar class Counter and makes increment%0A     * @param counter - counter%0A     */%0A    private void increment(Counter counter) %7B%0A        synchronized (this) %7B%0A            for (; counter.count %3C 10; ) %7B%0A                counter.count++;%0A                System.out.println(counter.count);%0A            %7D%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) throws InterruptedException %7B%0A        Counter counter = new Counter();%0A        Thread threadA = new Thread(counter);%0A        Thread threadB = new Thread(counter);%0A        threadA.start();%0A        threadB.start();%0A        threadA.join();%0A        threadB.join();%0A    %7D%0A%7D%0A

task 11102