2 // ========================================================================
3 // Copyright (c) 1995-2014 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;
25 import org.eclipse.jetty.util.component.LifeCycle;
27 /* ------------------------------------------------------------ */
30 * A specialization of Executor interface that provides reporting methods (eg {@link #getThreads()})
31 * and the option of configuration methods (e.g. @link {@link SizedThreadPool#setMaxThreads(int)}).
34 @ManagedObject("Pool of Threads")
35 public interface ThreadPool extends Executor
37 /* ------------------------------------------------------------ */
39 * Blocks until the thread pool is {@link LifeCycle#stop stopped}.
41 public void join() throws InterruptedException;
43 /* ------------------------------------------------------------ */
45 * @return The total number of threads currently in the pool
47 @ManagedAttribute("number of threads in pool")
48 public int getThreads();
50 /* ------------------------------------------------------------ */
52 * @return The number of idle threads in the pool
54 @ManagedAttribute("number of idle threads in pool")
55 public int getIdleThreads();
57 /* ------------------------------------------------------------ */
59 * @return True if the pool is low on threads
61 @ManagedAttribute("indicates the pool is low on available threads")
62 public boolean isLowOnThreads();
65 /* ------------------------------------------------------------ */
66 /* ------------------------------------------------------------ */
67 public interface SizedThreadPool extends ThreadPool
69 public int getMinThreads();
70 public int getMaxThreads();
71 public void setMinThreads(int threads);
72 public void setMaxThreads(int threads);