@@ -0,0 +1,893 @@
+/**%0A** To compile the file:%0A** javac Counting.java%0A** %0A** To run:%0A** java Counting%0A**%0A** After compiling/executing this code three times this is the output:%0A** 12660%0A** 12091%0A** 11903%0A**/%0Apublic class Counting %7B%0A  public static void main(String ...args) throws InterruptedException %7B%0A%0A      class Counter %7B%0A%0A        private int count = 0;%0A        public void increment() %7B ++count; %7D%0A        public int getCount() %7B return count; %7D%0A%0A      %7D%0A%0A      final Counter counter = new Counter();%0A%0A      class CountingThread extends Thread %7B%0A%0A        public void run()%7B%0A            for (int x = 0; x %3C 10000; ++x) %7B%0A              counter.increment();%0A            %7D%0A        %7D%0A      %7D%0A%0A        CountingThread t1 = new CountingThread();%0A        CountingThread t2 = new CountingThread();%0A%0A        t1.start(); t2.start();%0A        t1.join(); t2.join();%0A%0A        System.out.println(counter.getCount());%0A  %7D%0A%0A%7D%0A

Counting example, in theory the result should be 20000.