KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > io > ReentrantLock


1 /*
2  * ReentrantLock.java
3  *
4  * Created on 25. Juli 2006, 17:47
5  */

6 /*
7  * Copyright 2006 Schlichtherle IT Services
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package de.schlichtherle.io;
23
24 /**
25  * Similar to <code>java.util.concurrent.locks.Lock</code>,
26  * but simplified and adapted to the particular needs of TrueZIP.
27  * The subset of methods common to both this interface and its cousin
28  * in JSE 1.5 is identical in functionality.
29  * However, some other methods have been added here in order to suit
30  * the particular needs of TrueZIP (see {@link ArchiveController}).
31  *
32  * @author Christian Schlichtherle
33  * @version @version@
34  * @since TrueZIP 6.2
35  */

36 interface ReentrantLock {
37
38     /**
39      * Returns <code>true</code> if and only if the current thread has
40      * acquired this lock.
41      */

42     boolean isLocked();
43
44     /**
45      * Returns the number of times the current thread has successfully
46      * acquired this lock.
47      */

48     int lockCount();
49
50     /**
51      * Acquires this lock by the current thread, eventually blocking.
52      */

53     void lock();
54
55     /**
56      * Acquires this lock by the current thread unless it is interrupted,
57      * eventually blocking.
58      */

59     void lockInterruptibly() throws InterruptedException JavaDoc;
60
61     /**
62      * Acquires this lock if and only if it is available at the time of
63      * invocation by the current thread and returns <code>true</code>.
64      * Otherwise, If this lock is not available then <code>false</code>
65      * is returned.
66      */

67     boolean tryLock();
68
69     /**
70      * Releases this lock.
71      *
72      * @throws IllegalMonitorStateException If the current thread has not
73      * acquired this lock.
74      */

75     void unlock() throws IllegalMonitorStateException JavaDoc;
76 }
77
Popular Tags