Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / .metadata / .plugins / org.eclipse.core.resources / .history / b8 / 5084774992b6001815d6b875d9047b4d
diff --git a/JMCR-Stable/.metadata/.plugins/org.eclipse.core.resources/.history/b8/5084774992b6001815d6b875d9047b4d b/JMCR-Stable/.metadata/.plugins/org.eclipse.core.resources/.history/b8/5084774992b6001815d6b875d9047b4d
new file mode 100644 (file)
index 0000000..cd91d8f
--- /dev/null
@@ -0,0 +1,79 @@
+package edu.tamu.aser.rvtest_simple_tests;
+
+import static org.junit.Assert.*;
+
+import java.util.concurrent.locks.ReentrantLock;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import edu.tamu.aser.reexecution.JUnit4MCRRunner;
+
+@RunWith(JUnit4MCRRunner.class)
+public class RVExample {
+
+       private static int x;
+       private static int y;
+       private static Object lock = new Object();
+
+       public static void main(String[] args) {
+               Thread t1 = new Thread(new Runnable() {
+
+                       @Override
+                       public void run() {
+                               for (int i = 0; i < 2; i++) {
+                                       synchronized (lock) {
+                                               x = 0;
+                                       }
+                                       if (x > 0) {
+                                               y++;
+                                               x = 2;
+                                       }
+                               }
+                       }
+
+               });
+
+               Thread t2 = new Thread(new Runnable() {
+                       @Override
+                       public void run() {
+                               for (int i = 0; i < 2; i++) {
+                                       if (x > 1) {
+                                               if (y == 3) {
+                                                       fail("Find the error");
+                                               } else
+                                                       y = 2;
+                                       }
+                               }
+                       }
+
+               });
+               t1.start();
+               t2.start();
+
+               for (int i = 0; i < 2; i++) {
+                       synchronized (lock) {
+                               x = 1;
+                               y = 1;
+                       }
+               }
+               try {
+                       t1.join();
+                       t2.join();
+               } catch (InterruptedException e) {
+                       e.printStackTrace();
+               }
+       }
+
+       @Test
+       public void test() throws InterruptedException {
+               try {
+                       x = 0;
+                       y = 0;
+                       RVExample.main(null);
+               } catch (Exception e) {
+                       System.out.println("here");
+                       fail();
+               }
+       }
+}
\ No newline at end of file