daily pastebin goal
14%
SHARE
TWEET

Untitled

a guest Jan 17th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class RandomThread extends  Thread{
  2.  
  3.     static AtomicReference<Double> result = new AtomicReference<Double>(3.0);//test with 2, 0, -1, 58 : it's fun
  4.  
  5.     @Override
  6.     public void run() {
  7.        
  8.         try {
  9.             sleep((long)Math.random()*100);
  10.             Double cacheResult = result.get();
  11.             result.compareAndSet(cacheResult, cacheResult+Math.sin(cacheResult.doubleValue()));
  12.         } catch (InterruptedException e) {
  13.             e.printStackTrace();
  14.         }
  15.     }
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