+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
cccc41d
master
1import java .util .concurrent .atomic .*; 2class MyAtomicInteger extends AtomicInteger { 3public MyAtomicInteger (int val ) {super (val );} 4public int myAddAndGet (int delta ) { 5for (;;) { 6int current =get (); 7int next =current +delta ; 8if (compareAndSet (current ,next )) 9return next ; 10 } 11 } 12public static void main (String []args )throws Exception { 13MyAtomicInteger x =new MyAtomicInteger (10 ); 14System .out .println (x .myAddAndGet (5 )); 15 } 16}