public synchronized Object lockExclusive() throws IOException {
        while (myLock != null) {
            try {
                wait();
            } catch (InterruptedException ex) {
                throw new IOException(ex);
            }
        }
        myLock = getLockingObject();
        return myLock;
    }