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.
9 // The Eclipse Public License is available at
10 // http://www.eclipse.org/legal/epl-v10.html
12 // The Apache License v2.0 is available at
13 // http://www.opensource.org/licenses/apache2.0.php
15 // You may elect to redistribute this code under either of these licenses.
16 // ========================================================================
19 package org.eclipse.jetty.util.thread;
21 import java.util.concurrent.Executor;
23 import org.eclipse.jetty.util.annotation.ManagedAttribute;
24 import org.eclipse.jetty.util.annotation.ManagedObject;
26 /* ------------------------------------------------------------ */
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)}).
33 @ManagedObject("Pool of Threads")
34 public interface ThreadPool extends Executor
36 /* ------------------------------------------------------------ */
38 * Blocks until the thread pool is {@link LifeCycle#stop stopped}.
40 public void join() throws InterruptedException;
42 /* ------------------------------------------------------------ */
44 * @return The total number of threads currently in the pool
46 @ManagedAttribute("number of threads in pool")
47 public int getThreads();
49 /* ------------------------------------------------------------ */
51 * @return The number of idle threads in the pool
53 @ManagedAttribute("number of idle threads in pool")
54 public int getIdleThreads();
56 /* ------------------------------------------------------------ */
58 * @return True if the pool is low on threads
60 @ManagedAttribute("indicates the pool is low on available threads")
61 public boolean isLowOnThreads();
64 /* ------------------------------------------------------------ */
65 /* ------------------------------------------------------------ */
66 public interface SizedThreadPool extends ThreadPool
68 public int getMinThreads();
69 public int getMaxThreads();
70 public void setMinThreads(int threads);
71 public void setMaxThreads(int threads);