SHARE
TWEET

Untitled

a guest Dec 9th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.ArrayList;
  2.  
  3. public class MutexCheckingFramework {
  4.  
  5.     public static void main(String[] args) {
  6.       //test(new LocklessRunnable());
  7.       test(new DekkerLockRunnable(new DekkerLock()));
  8.     }
  9.  
  10.     private static void test(Runnable runnable) {
  11.         int numOfThreads = 2;
  12.         ArrayList<Thread> threads = new ArrayList<>();
  13.  
  14.         for (int i = 0;  i < numOfThreads; i++) {
  15.             threads.add(new Thread(runnable));
  16.         }
  17.  
  18.         for(Thread thread: threads) {
  19.             thread.start();
  20.         }
  21.  
  22.         for(Thread thread: threads) {
  23.             try {
  24.                 thread.join();
  25.             } catch (InterruptedException x) {
  26.                 x.printStackTrace();
  27.             }
  28.         }
  29.  
  30.         System.out.println("----------------------------------------------------");
  31.         System.out.println(("Counter: " + DekkerLockRunnable.count));
  32.         System.out.println(("Counter: " + LocklessRunnable.counter));
  33.         System.out.println("----------------------------------------------------");
  34.     }
  35.  
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top