Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RandomThread extends Thread{
- static AtomicReference<Double> result = new AtomicReference<Double>(3.0);//test with 2, 0, -1, 58 : it's fun
- @Override
- public void run() {
- try {
- sleep((long)Math.random()*100);
- Double cacheResult = result.get();
- result.compareAndSet(cacheResult, cacheResult+Math.sin(cacheResult.doubleValue()));
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment