SHARE
TWEET

Untitled

a guest Dec 9th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class LocklessRunnable implements Runnable {
  2.     public static int counter = 0;
  3.  
  4.     public LocklessRunnable() {
  5.         System.out.println("Creating new thread...");
  6.     }
  7.  
  8.     @Override
  9.     public void run() {
  10.         for (int i = 0; i < 1000000; i++) {
  11.             f();
  12.         }
  13.     }
  14.  
  15.     private void f() {
  16.         counter++;
  17.     }
  18. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top