Skip to content

Instantly share code, notes, and snippets.

@ivanursul
Created August 13, 2015 13:42
Show Gist options
  • Select an option

  • Save ivanursul/cf75f37feb51fc54e3a7 to your computer and use it in GitHub Desktop.

Select an option

Save ivanursul/cf75f37feb51fc54e3a7 to your computer and use it in GitHub Desktop.
Lock.java for www.ivanursul.com
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();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment