public class Lock
{
    private boolean busy = false;
	
    public synchronized void enter () throws InterruptedException
    {
        while (busy)
        {
            wait();
        }
        busy = true;
    }
	
    public synchronized void enterWithXH () throws InterruptedException
    {
        while (busy)
        {
            try
            {
                wait();
            }
            catch(InterruptedException e)
            {
                throw new InterruptedException("enter wait interrupted");
            }
        }
        busy = true;
    }
	
    public synchronized void exit ()
    {
        busy = false;
        notify();
    }
}