Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- public class MutexCheckingFramework {
- public static void main(String[] args) {
- //test(new LocklessRunnable());
- test(new DekkerLockRunnable(new DekkerLock()));
- }
- private static void test(Runnable runnable) {
- int numOfThreads = 2;
- ArrayList<Thread> threads = new ArrayList<>();
- for (int i = 0; i < numOfThreads; i++) {
- threads.add(new Thread(runnable));
- }
- for(Thread thread: threads) {
- thread.start();
- }
- for(Thread thread: threads) {
- try {
- thread.join();
- } catch (InterruptedException x) {
- x.printStackTrace();
- }
- }
- System.out.println("----------------------------------------------------");
- System.out.println(("Counter: " + DekkerLockRunnable.count));
- System.out.println(("Counter: " + LocklessRunnable.counter));
- System.out.println("----------------------------------------------------");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement