]> WPIA git - gigi.git/blob - lib/jetty/org/eclipse/jetty/util/thread/ThreadPool.java
updating jetty to jetty-9.2.16.v2016040
[gigi.git] / lib / jetty / org / eclipse / jetty / util / thread / ThreadPool.java
1 //
2 //  ========================================================================
3 //  Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
4 //  ------------------------------------------------------------------------
5 //  All rights reserved. This program and the accompanying materials
6 //  are made available under the terms of the Eclipse Public License v1.0
7 //  and Apache License v2.0 which accompanies this distribution.
8 //
9 //      The Eclipse Public License is available at
10 //      http://www.eclipse.org/legal/epl-v10.html
11 //
12 //      The Apache License v2.0 is available at
13 //      http://www.opensource.org/licenses/apache2.0.php
14 //
15 //  You may elect to redistribute this code under either of these licenses.
16 //  ========================================================================
17 //
18
19 package org.eclipse.jetty.util.thread;
20
21 import java.util.concurrent.Executor;
22
23 import org.eclipse.jetty.util.annotation.ManagedAttribute;
24 import org.eclipse.jetty.util.annotation.ManagedObject;
25
26 /* ------------------------------------------------------------ */
27 /** ThreadPool.
28  * 
29  * A specialization of Executor interface that provides reporting methods (eg {@link #getThreads()})
30  * and the option of configuration methods (e.g. @link {@link SizedThreadPool#setMaxThreads(int)}). 
31  *
32  */
33 @ManagedObject("Pool of Threads")
34 public interface ThreadPool extends Executor
35 {
36     /* ------------------------------------------------------------ */
37     /**
38      * Blocks until the thread pool is {@link LifeCycle#stop stopped}.
39      */
40     public void join() throws InterruptedException;
41
42     /* ------------------------------------------------------------ */
43     /**
44      * @return The total number of threads currently in the pool
45      */
46     @ManagedAttribute("number of threads in pool")
47     public int getThreads();
48
49     /* ------------------------------------------------------------ */
50     /**
51      * @return The number of idle threads in the pool
52      */
53     @ManagedAttribute("number of idle threads in pool")
54     public int getIdleThreads();
55     
56     /* ------------------------------------------------------------ */
57     /**
58      * @return True if the pool is low on threads
59      */
60     @ManagedAttribute("indicates the pool is low on available threads")
61     public boolean isLowOnThreads();
62     
63
64     /* ------------------------------------------------------------ */
65     /* ------------------------------------------------------------ */
66     public interface SizedThreadPool extends ThreadPool
67     {
68         public int getMinThreads();
69         public int getMaxThreads();
70         public void setMinThreads(int threads);
71         public void setMaxThreads(int threads);
72     }
73 }