package ru.job4j.synchronize;

import org.junit.Test;

/**
 * Тест для класса Count.
 * @author Vitaly Kovrov (mailto:virtaly@ya.ru)
 * @version 0.1
 * @since 0.1
 */
public class CountTest {

    private class CountThread extends Thread {
        private final Count counter;

        private CountThread(Count counter) {
            this.counter = counter;
        }

        @Override
        public void run() {
            this.counter.increment();
        }
    }

    /**
     * Тест для метода increment.
     * Использование метода для работы двух потоков с общим ресурсом.
     */
    @Test
    public void whenExecute2ThreadThen2() {
        Count counter = new Count();
        Thread firstThread = new CountThread(counter);
        Thread secondThread = new CountThread(counter);
        firstThread.start();
        secondThread.start();
        try {
            firstThread.join();
            secondThread.join();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        }
        System.out.println(counter.getValue());
    }
}
@@ -194,88 +194,355 @@
     
-private class CountThread extends Thread %7B%0A        private final Count counter;%0A
+/**%0A     * %D0%9A%D0%BB%D0%B0%D1%81%D1%81 %D0%B4%D0%BB%D1%8F %D0%BF%D0%BE%D1%82%D0%BE%D0%BA%D0%B0 %D1%83%D0%B2%D0%B5%D0%BB%D0%B8%D1%87%D0%B5%D0%BD%D0%B8%D1%8F %D1%81%D1%87%D0%B5%D1%82%D1%87%D0%B8%D0%BA%D0%B0.%0A     * @author vkovrov%0A     * @version 0.1%0A     * @since 0.1%0A     */%0A    private class CountThread extends Thread %7B%0A%0A        /**%0A         * %D0%9F%D0%BE%D0%BB%D0%B5 %D0%B4%D0%BB%D1%8F %D1%81%D1%87%D0%B5%D1%82%D1%87%D0%B8%D0%BA%D0%B0.%0A         */%0A        private final Count counter;%0A%0A        /**%0A         * %D0%9A%D0%BE%D0%BD%D1%81%D1%82%D1%80%D1%83%D0%BA%D1%82%D0%BE%D1%80 %D0%BA%D0%BB%D0%B0%D1%81%D1%81%D0%B0.%0A         * @param counter %D1%81%D1%87%D0%B5%D1%82%D1%87%D0%B8%D0%BA.%0A         */
 %0A   
@@ -626,24 +626,99 @@
 %0A        %7D%0A%0A
+        /**%0A         * %D0%9C%D0%B5%D1%82%D0%BE%D0%B4 %D0%B4%D0%BB%D1%8F %D0%B7%D0%B0%D0%BF%D1%83%D1%81%D0%BA%D0%B0 %D0%BF%D0%BE%D1%82%D0%BE%D0%BA%D0%B0 %D0%BD%D0%B0 %D0%B2%D1%8B%D0%BF%D0%BE%D0%BB%D0%BD%D0%B5%D0%BD%D0%B8%D0%B5.%0A         */%0A
         @Ove

add comments - 1. класс Count и метод int increment() [#1102]