KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > aspects > asynchronous > ThreadManager


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22
23 package org.jboss.aspects.asynchronous;
24
25 /**
26  * @author <a HREF="mailto:chussenet@yahoo.com">{Claude Hussenet Independent Consultant}</a>.
27  * @version <tt>$Revision: 37406 $</tt>
28  */

29
30 public interface ThreadManager
31 {
32
33    /**
34     * Set the policy for blocked execution to be to wait until a thread
35     * <p/>
36     * is available.
37     * <p/>
38     * <p/>
39     * <p/>
40     * OR
41     * <p/>
42     * <p/>
43     * <p/>
44     * Set the policy for blocked execution to be to
45     * <p/>
46     * throw a RuntimeException.
47     */

48
49    public abstract void setWaitWhenPoolSizeIsFull(boolean value);
50
51    /**
52     * return the policy when the pool is full
53     */

54
55    public abstract boolean getWaitWhenPoolSizeIsFull();
56
57    /**
58     * Set the maximum number of threads to use.
59     */

60
61    public abstract void setMaximumPoolSize(int maximumPoolSize);
62
63    /**
64     * Return the maximum number of threads to use.
65     */

66
67    public abstract int getMaximumPoolSize();
68
69    /**
70     * Set the minimum number of threads to use.
71     */

72
73    public abstract void setMinimumPoolSize(int minimumPoolSize);
74
75    /**
76     * Return the maximum number of threads to simultaneously execute
77     */

78
79    public abstract int getMinimumPoolSize();
80
81    /**
82     * Set the number of milliseconds to keep threads alive waiting for
83     * <p/>
84     * new commands. A negative value means to wait forever. A zero
85     * <p/>
86     * value means not to wait at all.
87     */

88
89    public abstract void setKeepAliveTime(long time);
90
91    /**
92     * Return the number of milliseconds to keep threads alive waiting
93     * <p/>
94     * for new commands. A negative value means to wait forever. A zero
95     * <p/>
96     * value means not to wait at all.
97     */

98
99    public abstract long getKeepAliveTime();
100
101    /**
102     * Return the current number of active threads in the pool.
103     */

104
105    public abstract long getPoolSize();
106
107    /**
108     * Return the response from an asynchronous task
109     * <p/>
110     * The call returns within the timeout defined
111     * <p/>
112     * in the process method
113     */

114
115    public abstract ThreadManagerResponse waitForResponse(AsynchronousTask input);
116
117    /**
118     * Return an array of responses from an array of asynchronous task
119     * <p/>
120     * The call returns within the maximum timeout from the array of tasks
121     */

122
123    public abstract ThreadManagerResponse[] waitForResponses(AsynchronousTask input[]);
124
125    /**
126     * Create, start and return a new asynchronous task from
127     * <p/>
128     * <p/>
129     * <p/>
130     * <p><b>ppmRequest</b> class instance defining the task parameters.
131     */

132
133    public abstract AsynchronousTask process(ThreadManagerRequest ppmRequest);
134
135
136    public abstract boolean isPooling();
137
138    public abstract void setPooling(boolean isPooling);
139
140 }
141
Popular Tags