+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
9cde2af
master
1class Cell { 2int value ; 3public synchronized int getValue () { 4return value ; 5 } 6public synchronized void setValue (int i ) { 7value =i ; 8 } 9protected void doSwap (Cell x ) { 10int temp =getValue (); 11setValue (x .getValue ()); 12x .setValue (temp ); 13 } 14public void swap (Cell x ) { 15if (this ==x ) 16return ; 17if (System .identityHashCode (this ) 18 <System .identityHashCode (x )) 19synchronized (this ) { 20synchronized (x ) { 21doSwap (x ); 22 } 23 } 24else 25synchronized (x ) { 26synchronized (this ) { 27x .doSwap (this ); 28 } 29 } 30 } 31}