+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
5a5a002
master
1//http://tutorials.jenkov.com/java-concurrency/nested-monitor-lockout.html 2public class NestedMon { 3protected Object monitorObject =new Object (); 4protected boolean isLocked =false ; 5 6public void lock ()throws InterruptedException { 7synchronized (this ){ 8while (isLocked ){ 9synchronized (this .monitorObject ){ 10this .monitorObject .wait (); 11 } 12 } 13isLocked =true ; 14 } 15 } 16 17public void unlock (){ 18synchronized (this ){ 19this .isLocked =false ; 20synchronized (this .monitorObject ){ 21this .monitorObject .notify (); 22 } 23 } 24 } 25}