public synchronized void lock()
    {
    if (value > 0)
        {
        value--;
        }
    else
        {
        try
            {
            waiting++;
            if (message != null) {
                System.err.println(message);
            }
            wait();
            }
        catch (InterruptedException e)
            {
            System.err.println(e.getMessage());
            }
        }
    }