Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1974 jgill 1
/**
2
 * AntShield - A project release tool for ant.
3
 */
4
package com.erggroup.mass.ant;
5
 
6
/**
7
 * AntShieldLock
8
 * A locking mechanism to keep frames open until explicitly closed.
9
 */
10
public class AntShieldLock
11
{
12
    private boolean locked = false;
13
 
14
    public AntShieldLock()
15
    {
16
    }
17
 
18
    /**
19
     * Lock the current thread.
20
     */
21
    public synchronized void acquire()
22
    {
23
        if (!locked)
24
        {
25
            locked = true;
26
            try
27
            {
28
                wait();
29
            }
30
            catch (InterruptedException e)
31
            {
32
                locked = false;
33
            }
34
        }
35
    }
36
 
37
    /**
38
     * Release the lock.
39
     */
40
    public synchronized void release()
41
    {
42
        if (locked)
43
        {
44
            locked = false;
45
            notifyAll();
46
        }
47
    }
48
}