Advertisement
Guest User

Untitled

a guest
Nov 18th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.     public static void main(String[] args) {       
  2.         int numOfThreads = 1000;
  3.         UnSafePublication uspObj = new UnSafePublication();
  4.        
  5.         Runnable initializeRunnable = () -> {
  6.             uspObj.initialize();
  7.         };
  8.        
  9.         Runnable assertRunnable = () -> {
  10.             try {
  11.                 Thread.sleep(110);
  12.             } catch (InterruptedException e) {
  13.                 // TODO Auto-generated catch block
  14.                 e.printStackTrace();
  15.             }
  16.             if (uspObj.holder == null) {
  17.                 uspObj.holder.assertSanity(42);
  18.             } else {
  19.                 uspObj.holder.assertSanity(uspObj.holder.getHolderValue());
  20.             }
  21.         };
  22.        
  23.         for (int i = 0; i < numOfThreads; i++) {
  24.                 Thread iR = new Thread(initializeRunnable);
  25.                 Thread aR = new Thread(assertRunnable);
  26.                 iR.start();
  27.                 aR.start();
  28.             }      
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement