ThreadPool.java revision 608:7e06bf1dcb09
1/*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.corba.se.spi.orbutil.threadpool;
27
28import java.io.Closeable;
29
30/** This interface defines a thread pool execution service.  The ORB uses this
31 * interface, which preceeds the JDK 5 ExecutorService.  Note that the close
32 * method must be called in order to reclaim thread resources.
33 */
34public interface ThreadPool extends Closeable
35{
36
37    /**
38    * This method will return any instance of the WorkQueue. If the ThreadPool
39    * instance only services one WorkQueue then that WorkQueue instance will
40    * be returned. If there are more than one WorkQueues serviced by this
41    * ThreadPool, then this method would return a WorkQueue based on the
42    * implementation of the class that implements this interface. For PE 8.0 we
43    * would return a WorkQueue in a roundrobin fashion everytime this method
44    * is called. In the future we could allow pluggability of  Policy objects for this.
45    */
46    public WorkQueue getAnyWorkQueue();
47
48    /**
49    * This method will return an instance of the of the WorkQueue given a queueId.
50    * This will be useful in situations where there are more than one WorkQueues
51    * managed by the ThreadPool and the user of the ThreadPool wants to always use
52    * the same WorkQueue for doing the Work.
53    * If the number of WorkQueues in the ThreadPool are 10, then queueIds will go
54    * from 0-9
55    *
56    * @throws NoSuchWorkQueueException thrown when queueId passed is invalid
57    */
58    public WorkQueue getWorkQueue(int queueId) throws NoSuchWorkQueueException;
59
60    /**
61    * This method will return the number of WorkQueues serviced by the threadpool.
62    */
63    public int numberOfWorkQueues();
64
65    /**
66    * This method will return the minimum number of threads maintained by the threadpool.
67    */
68    public int minimumNumberOfThreads();
69
70    /**
71    * This method will return the maximum number of threads in the threadpool at any
72    * point in time, for the life of the threadpool
73    */
74    public int maximumNumberOfThreads();
75
76    /**
77    * This method will return the time in milliseconds when idle threads in the threadpool are
78    * removed.
79    */
80    public long idleTimeoutForThreads();
81
82    /**
83    * This method will return the current number of threads in the threadpool. This method
84    * returns a value which is not synchronized.
85    */
86    public int currentNumberOfThreads();
87
88    /**
89    * This method will return the number of available threads in the threadpool which are
90     * waiting for work. This method returns a value which is not synchronized.
91    */
92    public int numberOfAvailableThreads();
93
94    /**
95    * This method will return the number of busy threads in the threadpool
96    * This method returns a value which is not synchronized.
97    */
98    public int numberOfBusyThreads();
99
100    /**
101    * This method returns the number of Work items processed by the threadpool
102    */
103    public long currentProcessedCount();
104
105     /**
106     * This method returns the average elapsed time taken to complete a Work
107     * item.
108     */
109    public long averageWorkCompletionTime();
110
111    /**
112    * This method will return the name of the threadpool.
113    */
114    public String getName();
115
116}
117
118// End of file.
119