KickJava   Java API By Example, From Geeks To Geeks.

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


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 RunnableManager interface describes the functionality of an
20  * implementation running commands in the background.
21  *
22  * @author <a HREF="mailto:giacomo.at.apache.org">Giacomo Pati</a>
23  * @version CVS $Id: RunnableManager.java 56786 2004-11-06 23:12:39Z giacomo $
24  */

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

29     /** The role name */
30     String JavaDoc ROLE = RunnableManager.class.getName( );
31
32     //~ Methods ----------------------------------------------------------------
33

34     /**
35      * Create a shared ThreadPool with a specific {@link ThreadFactory}
36      *
37      * @param name The name of the thread pool
38      * @param queueSize The size of the queue
39      * @param maxPoolSize The maximum number of threads
40      * @param minPoolSize The maximum number of threads
41      * @param priority The priority of threads created by this pool. This is
42      * one of {@link Thread#MIN_PRIORITY}, {@link
43      * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY}
44      * @param isDaemon Whether or not thread from the pool should run in daemon
45      * mode
46      * @param keepAliveTime How long should a thread be alive for new work to
47      * be done before it is GCed
48      * @param blockPolicy What's the blocking policy is resources are exhausted
49      * @param shutdownGraceful Should we wait for the queue to finish all
50      * pending commands?
51      * @param shutdownWaitTime After what time a normal shutdown should take
52      * into account if a graceful shutdown has not come to an end
53      */

54     void createPool( String JavaDoc name,
55                      int queueSize,
56                      int maxPoolSize,
57                      int minPoolSize,
58                      int priority,
59                      final boolean isDaemon,
60                      long keepAliveTime,
61                      String JavaDoc blockPolicy,
62                      boolean shutdownGraceful,
63                      int shutdownWaitTime );
64
65     /**
66      * Create a private ThreadPool with a specific {@link ThreadFactory}
67      *
68      * @param queueSize The size of the queue
69      * @param maxPoolSize The maximum number of threads
70      * @param minPoolSize The maximum number of threads
71      * @param priority The priority of threads created by this pool. This is
72      * one of {@link Thread#MIN_PRIORITY}, {@link
73      * Thread#NORM_PRIORITY}, or {@link Thread#MAX_PRIORITY}
74      * @param isDaemon Whether or not thread from the pool should run in daemon
75      * mode
76      * @param keepAliveTime How long should a thread be alive for new work to
77      * be done before it is GCed
78      * @param blockPolicy What's the blocking policy is resources are exhausted
79      * @param shutdownGraceful Should we wait for the queue to finish all
80      * pending commands?
81      * @param shutdownWaitTime After what time a normal shutdown should take
82      * into account if a graceful shutdown has not come to an end
83      *
84      * @return The newly created <code>ThreadPool</code>
85      */

86     ThreadPool createPool( int queueSize,
87                            int maxPoolSize,
88                            int minPoolSize,
89                            int priority,
90                            final boolean isDaemon,
91                            long keepAliveTime,
92                            String JavaDoc blockPolicy,
93                            boolean shutdownGraceful,
94                            int shutdownWaitTime );
95
96     /**
97      * Immediate Execution of a runnable in the background
98      *
99      * @param command The command to execute
100      */

101     void execute( Runnable JavaDoc command );
102
103     /**
104      * Immediate Execution of a runnable in the background
105      *
106      * @param command The command to execute
107      * @param delay The delay before first run
108      */

109     void execute( Runnable JavaDoc command,
110                   long delay );
111
112     /**
113      * Immediate Execution of a runnable in the background
114      *
115      * @param command The command to execute
116      * @param delay The delay before first run
117      * @param interval The interval of repeated runs
118      */

119     void execute( Runnable JavaDoc command,
120                   long delay,
121                   long interval );
122
123     /**
124      * Immediate Execution of a runnable in the background
125      *
126      * @param threadPoolName The thread pool to use
127      * @param command The command to execute
128      */

129     void execute( String JavaDoc threadPoolName,
130                   Runnable JavaDoc command );
131
132     /**
133      * Immediate Execution of a runnable in the background
134      *
135      * @param threadPoolName The thread pool to use
136      * @param command The command to execute
137      * @param delay The delay before first run
138      */

139     void execute( String JavaDoc threadPoolName,
140                   Runnable JavaDoc command,
141                   long delay );
142
143     /**
144      * Delayed and repeated Execution of a runnable in the background
145      *
146      * @param threadPoolName The thread pool to use
147      * @param command The command to execute
148      * @param delay The delay before first run
149      * @param interval The interval of repeated runs
150      */

151     void execute( String JavaDoc threadPoolName,
152                   Runnable JavaDoc command,
153                   long delay,
154                   long interval );
155
156     /**
157      * Remove a {@link Runnable} from the execution stack
158      *
159      * @param command The command to be removed
160      */

161     void remove( Runnable JavaDoc command );
162 }
163
Popular Tags