KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > thread > ThreadPool


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

16 package org.apache.cocoon.components.thread;
17
18 /**
19  * The ThreadPool interface gives access to methods needed to inspect and use
20  * of a pool of threads
21  *
22  * @author <a HREF="mailto:giacomo.at.apache.org">Giacomo Pati</a>
23  * @version CVS $Id: ThreadPool.java 56702 2004-11-05 22:52:05Z giacomo $
24  */

25 public interface ThreadPool
26 {
27     //~ Instance fields --------------------------------------------------------
28

29     /** ThreadPool block policy ABORT */
30     String JavaDoc POLICY_ABORT = "ABORT";
31
32     /** ThreadPool block policy DISCARD */
33     String JavaDoc POLICY_DISCARD = "DISCARD";
34
35     /** ThreadPool block policy DISCARD-OLDEST */
36     String JavaDoc POLICY_DISCARD_OLDEST = "DISCARDOLDEST";
37
38     /** ThreadPool block policy RUN */
39     String JavaDoc POLICY_RUN = "RUN";
40
41     /** ThreadPool block policy WAIT */
42     String JavaDoc POLICY_WAIT = "WAIT";
43
44     /** The Role name */
45     String JavaDoc ROLE = ThreadPool.class.getName( );
46
47     //~ Methods ----------------------------------------------------------------
48

49     /**
50      * The blocking policy used
51      *
52      * @return DOCUMENT ME!
53      */

54     String JavaDoc getBlockPolicy( );
55
56     /**
57      * How long will a thread in this pool be idle before it is allowed to be
58      * garbage collected
59      *
60      * @return maximum idle time
61      */

62     long getKeepAliveTime( );
63
64     /**
65      * How many threads are in this pool at maximum
66      *
67      * @return maximum size of pool
68      */

69     int getMaximumPoolSize( );
70
71     /**
72      * Maximum size of the queue
73      *
74      * @return current size of queue
75      */

76     int getMaximumQueueSize( );
77
78     /**
79      * How many threads are in this pool at minimum
80      *
81      * @return minimum size of pool
82      */

83     int getMinimumPoolSize( );
84
85     /**
86      * The Name of this thread pool
87      *
88      * @return The name
89      */

90     String JavaDoc getName( );
91
92     /**
93      * How many threads are currently in this pool
94      *
95      * @return current size of pool
96      */

97     int getPoolSize( );
98
99     /**
100      * Get the thread priority used by this pool
101      *
102      * @return current size of queue
103      */

104     int getPriority( );
105
106     /**
107      * Current size of the queue.
108      *
109      * @return current size of queue. If the size of the queue is not
110      * maintained by an implementation -1 should be returned.
111      */

112     int getQueueSize( );
113
114     /**
115      * Whether this ThreadPool has a queue
116      *
117      * @return Returns true if this ThreadPool has a queue
118      */

119     boolean isQueued( );
120
121     /**
122      * Returns true if a shutDown method has succeeded in terminating all
123      * threads
124      *
125      * @return Whether a shutDown method has succeeded in terminating all
126      * threads
127      */

128     boolean isTerminatedAfterShutdown( );
129
130     /**
131      * Execute a command using this pool
132      *
133      * @param command a {@link Runnable} to execute
134      *
135      * @throws InterruptedException In case of interruption
136      */

137     void execute( Runnable JavaDoc command )
138         throws InterruptedException JavaDoc;
139
140     /**
141      * Terminates all threads possibly awaiting processing all elements
142      * currently in queue.
143      */

144     void shutdown( );
145 }
146
Popular Tags