KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sape > carbon > services > threadpool > ThreadPoolConfiguration


1 /*
2  * The contents of this file are subject to the Sapient Public License
3  * Version 1.0 (the "License"); you may not use this file except in compliance
4  * with the License. You may obtain a copy of the License at
5  * http://carbon.sf.net/License.html.
6  *
7  * Software distributed under the License is distributed on an "AS IS" basis,
8  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
9  * the specific language governing rights and limitations under the License.
10  *
11  * The Original Code is The Carbon Component Framework.
12  *
13  * The Initial Developer of the Original Code is Sapient Corporation
14  *
15  * Copyright (C) 2003 Sapient Corporation. All Rights Reserved.
16  */

17
18 package org.sape.carbon.services.threadpool;
19
20 import org.sape.carbon.core.component.ComponentConfiguration;
21
22 /**
23  * Configuration for the DefaultThreadPoolImpl.
24  *
25  * <br>Copyright 2002 Sapient
26  * @since carbon 1.1
27  * @author Douglas Voet, Nov 5, 2002
28  * @version $Revision: 1.6 $($Author: dvoet $ / $Date: 2003/11/20 18:49:59 $)
29  */

30 public interface ThreadPoolConfiguration extends ComponentConfiguration {
31     /**
32      * ThreadPoolSize determines the number of threads in the pool. Depending
33      * on the the values of InitialThreadCount and KeepAliveTime, there may
34      * be fewer threads in the pool, but never more. Required.
35      */

36     int getThreadPoolSize();
37     /**
38      * ThreadPoolSize determines the number of threads in the pool. Depending
39      * on the the values of InitialThreadCount and KeepAliveTime, there may
40      * be fewer threads in the pool, but never more. Required.
41      */

42     void setThreadPoolSize(int size);
43
44     /**
45      * FailureListCapacity limits the number of failures that are tracked.
46      * When this list fills, the oldest failure is removed before adding
47      * the newest failure. Defaults to 100.
48      */

49     int FailureListCapacity = 100;
50     /**
51      * FailureListCapacity limits the number of failures that are tracked.
52      * When this list fills, the oldest failure is removed before adding
53      * the newest failure. Defaults to 100.
54      */

55     int getFailureListCapacity();
56     /**
57      * FailureListCapacity limits the number of failures that are tracked.
58      * When this list fills, the oldest failure is removed before adding
59      * the newest failure. Defaults to 100.
60      */

61     void setFailureListCapacity(int capacity);
62
63     /**
64      * Tells the thread pool whether or not to use daemon threads. Defaults
65      * to true. From the java.lang.Thread javadoc,
66      * "The Java Virtual Machine exits when the only threads running are all
67      * daemon threads."
68      *
69      * @see Thread#setDaemon(boolean)
70      */

71     boolean UseDaemonThreads = true;
72     /**
73      * Tells the thread pool whether or not to use daemon threads. Defaults
74      * to true. From the java.lang.Thread javadoc,
75      * "The Java Virtual Machine exits when the only threads running are all
76      * daemon threads."
77      *
78      * @see Thread#setDaemon(boolean)
79      */

80     boolean isUseDaemonThreads();
81     /**
82      * Tells the thread pool whether or not to use daemon threads. Defaults
83      * to true. From the java.lang.Thread javadoc,
84      * "The Java Virtual Machine exits when the only threads running are all
85      * daemon threads."
86      *
87      * @see Thread#setDaemon(boolean)
88      */

89     void setUseDaemonThreads(boolean useDaemonThreads);
90     
91     /**
92      * If a thread in the pool has been idle longer than KeepAliveTime
93      * (measured in milliseconds), it
94      * will be allowed to terminate, releasing its resources. If this is set
95      * to 0, the thread will not terminate unless interrupted.
96      * Defaults to 300000 (5 minutes).
97      */

98     int KeepAliveTime = 300000;
99     /**
100      * If a thread in the pool has been idle longer than KeepAliveTime
101      * (measured in milliseconds), it
102      * will be allowed to terminate, releasing its resources. If this is set
103      * to 0, the thread will not terminate unless interrupted.
104      * Defaults to 300000 (5 minutes).
105      */

106     int getKeepAliveTime();
107     /**
108      * If a thread in the pool has been idle longer than KeepAliveTime
109      * (measured in milliseconds), it
110      * will be allowed to terminate, releasing its resources. If this is set
111      * to 0, the thread will not terminate unless interrupted.
112      * Defaults to 300000 (5 minutes).
113      */

114     void setKeepAliveTime(int milliseconds);
115     
116     /**
117      * QueueFullPolicy determines how the thread pool deals with new execute
118      * requests when the pending queue is already full.
119      * Defaults to QueueFullPolicyEnum.RUN which means that the new task will
120      * execute on the current thread, not a pooled thread.
121      *
122      * @see QueueFullPolicyEnum
123      */

124     QueueFullPolicyEnum QueueFullPolicy = QueueFullPolicyEnum.RUN;
125     /**
126      * QueueFullPolicy determines how the thread pool deals with new execute
127      * requests when the pending queue is already full.
128      * Defaults to QueueFullPolicyEnum.RUN which means that the new task will
129      * execute on the current thread, not a pooled thread.
130      *
131      * @see QueueFullPolicyEnum
132      */

133     QueueFullPolicyEnum getQueueFullPolicy();
134     /**
135      * QueueFullPolicy determines how the thread pool deals with new execute
136      * requests when the pending queue is already full.
137      * Defaults to QueueFullPolicyEnum.RUN which means that the new task will
138      * execute on the current thread, not a pooled thread.
139      *
140      * @see QueueFullPolicyEnum
141      */

142     void setQueueFullPolicy(QueueFullPolicyEnum policy);
143     
144     /**
145      * TaskQueueSize limits the number of tasks that can be waiting for
146      * execution. This is required and must be greater than 0.
147      */

148     int getTaskQueueSize();
149     /**
150      * TaskQueueSize limits the number of tasks that can be waiting for
151      * execution. This is required and must be greater than 0.
152      */

153     void setTaskQueueSize(int size);
154     
155     /**
156      * InitialThreadCount tells the thread pool how many threads to create
157      * when it starts. Note that if KeepAliveTime is non-zero, these threads
158      * may terminate. Defaults to 0.
159      */

160     int InitialThreadCount = 0;
161     int getInitialThreadCount();
162     void setInitialThreadCount(int count);
163     
164     /**
165      * If DiscardQueuedTasksOnShutdown is true, ShutdownWaitTime tells the
166      * thread pool how long to wait in milliseconds for queued tasks to
167      * complete execution. Defaults to 1000 (1 second).
168      */

169     long ShutdownWaitTime = 1000;
170     /**
171      * If DiscardQueuedTasksOnShutdown is true, ShutdownWaitTime tells the
172      * thread pool how long to wait in milliseconds for queued tasks to
173      * complete execution. Defaults to 1000 (1 second).
174      */

175     long getShutdownWaitTime();
176     /**
177      * If DiscardQueuedTasksOnShutdown is true, ShutdownWaitTime tells the
178      * thread pool how long to wait in milliseconds for queued tasks to
179      * complete execution. Defaults to 1000 (1 second).
180      */

181     void setShutdownWaitTime(long milliseconds);
182     
183     /**
184      * DiscardQueuedTasksOnShutdown tells the thread pool whether or not to
185      * wait for queued tasks to complete execution when the service is stopped.
186      * Defaults to false.
187      */

188     boolean DiscardQueuedTasksOnShutdown = false;
189     /**
190      * DiscardQueuedTasksOnShutdown tells the thread pool whether or not to
191      * wait for queued tasks to complete execution when the service is stopped.
192      * Defaults to false.
193      */

194     boolean getDiscardQueuedTasksOnShutdown();
195     /**
196      * DiscardQueuedTasksOnShutdown tells the thread pool whether or not to
197      * wait for queued tasks to complete execution when the service is stopped.
198      * Defaults to false.
199      */

200     void setDiscardQueuedTasksOnShutdown(boolean discardTasks);
201 }
202
Popular Tags