Subversion Repositories DevTools

Rev

Blame | Last modification | View Log | RSS feed

/**
 * AntShield - A project release tool for ant.
 */
package com.erggroup.mass.ant;

/**
 * AntShieldLock
 * A locking mechanism to keep frames open until explicitly closed.
 */
public class AntShieldLock
{
    private boolean locked = false;

    public AntShieldLock()
    {
    }

    /**
     * Lock the current thread.
     */
    public synchronized void acquire()
    {
        if (!locked)
        {
            locked = true;
            try
            {
                wait();
            }
            catch (InterruptedException e)
            {
                locked = false;
            }
        }
    }

    /**
     * Release the lock.
     */
    public synchronized void release()
    {
        if (locked)
        {
            locked = false;
            notifyAll();
        }
    }
}