package com.greensnow25;

/**
 * public class Visibility.
 *
 * @author greensnow25.
 * @version 1.
 * @since 13.06.2017.
 */
public class Visibility {
    private int count;

    public Visibility(int count) {
        this.count = count;
    }

    public void inc(){
        count++;
    }

    public void runThread(){
        Thread one = new Thread(new Runnable() {
            @Override
            public void run() {
                inc();

            }
        });
        one.start();
        System.out.println(count);
    }

    public static void main(String[] args) {
        Visibility visibility = new Visibility(1);
        visibility.runThread();
        System.out.println(visibility.count);
    }
}

@@ -153,209 +153,268 @@
     
-private int count;%0A%0A    public Visibility(int count) %7B%0A        this.count = count;
+/**%0A     * counter.%0A     */%0A    private int count = 0;%0A    /**%0A     * first thread.
 %0A    
-%7D%0A
+ */
 %0A    p
-ublic void inc()%7B%0A        count++;
+rivate Thread two;%0A    /**%0A     * second thread.
 %0A    
-%7D%0A
+ */
 %0A    p
-ublic void runThread()%7B%0A        Thread one = new Thread(new
+rivate Thread one;%0A%0A    /**%0A     * create new myThread.%0A     */%0A    private class MyThread implements
  Run
@@ -418,25 +418,20 @@
 Runnable
-()
  %7B%0A
-    
+%0A
         
@@ -440,20 +440,16 @@
 verride%0A
-    
         
@@ -484,46 +484,268 @@
     
-    inc();%0A%0A            %7D%0A        %7D
+for (int i = 0; i != 100_000_000; i++) %7B%0A                count++;%0A            %7D%0A        %7D%0A    %7D%0A%0A    /**%0A     * run threads.%0A     */%0A    public void runThreads()  %7B%0A        this.one = new Thread(new MyThread());%0A        this.two = new Thread(new MyThread()
 );%0A
+%0A
     
@@ -773,41 +773,83 @@
     
-System.out.println(count);%0A    %7D%0A
+two.start();%0A%0A%0A    %7D%0A%0A    /**%0A     * main.%0A     * @param args args.%0A     */
 %0A   
@@ -887,16 +887,17 @@
 %5B%5D args)
+ 
  %7B%0A     
@@ -938,17 +938,16 @@
 ibility(
-1
 );%0A     
@@ -969,20 +969,93 @@
 unThread
+s
 ();%0A
+        while (visibility.one.isAlive() %7C%7C visibility.two.isAlive()) ;%0A%0A
         

Update date 21.06.17