1 import java.util.concurrent.atomic.AtomicBoolean;
3 public class ConcurrentCount {
4 static final int COUNT = 30000;
5 volatile static int count = COUNT;
6 volatile static AtomicBoolean lock = new AtomicBoolean(false);
10 public static void main(String args[]) {
17 if (lock.get()) continue;
33 if (lock.get()) continue;
45 //System.out.println("a = " + a);
46 //System.out.println("b = " + b);
47 //System.out.println("a + b = " + (a + b));
48 //System.out.println("count = " + count);
50 //Checks for concurrency error (which should be found when using model checking)
51 assert a + b == COUNT;
54 private static synchronized void decreaseCount() {