public synchronized void beginWrite(int blockNumber, byte[] buffer) {
        if (
                blockNumber < 0
                || blockNumber >= DISK_SIZE
                || buffer == null
                || buffer.length < BLOCK_SIZE)
        {
            throw new DiskException("Illegal disk write request: "
                        + " block number " + blockNumber
                        + " buffer " + buffer);
        }

        if (busy) {
            throw new DiskException("Disk write attempted "
                        + " while the disk was still busy.");
        }

        isWriting = true;
        this.buffer = buffer;
        targetBlock = blockNumber;
        requestQueued = true;

        notify();
    } // beginWrite(int, byte[])