1234567891011121314151617181920212223242526 |
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author LH
- */
- public class Lock{
- private boolean isLocked = false;
-
- public synchronized void lock()
- throws InterruptedException{
- while(isLocked){
- wait();
- }
- isLocked = true;
- }
-
- public synchronized void unlock(){
- isLocked = false;
- notify();
- }
- }
|