1 // 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. 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 org.eclipse.jetty.util.component.LifeCycle; 22 23 /* ------------------------------------------------------------ */ 24 /** ThreadPool. 25 * 26 * 27 */ 28 public interface ThreadPool 29 { 30 /* ------------------------------------------------------------ */ dispatch(Runnable job)31 public abstract boolean dispatch(Runnable job); 32 33 /* ------------------------------------------------------------ */ 34 /** 35 * Blocks until the thread pool is {@link LifeCycle#stop stopped}. 36 */ join()37 public void join() throws InterruptedException; 38 39 /* ------------------------------------------------------------ */ 40 /** 41 * @return The total number of threads currently in the pool 42 */ getThreads()43 public int getThreads(); 44 45 /* ------------------------------------------------------------ */ 46 /** 47 * @return The number of idle threads in the pool 48 */ getIdleThreads()49 public int getIdleThreads(); 50 51 /* ------------------------------------------------------------ */ 52 /** 53 * @return True if the pool is low on threads 54 */ isLowOnThreads()55 public boolean isLowOnThreads(); 56 57 58 /* ------------------------------------------------------------ */ 59 /* ------------------------------------------------------------ */ 60 public interface SizedThreadPool extends ThreadPool 61 { getMinThreads()62 public int getMinThreads(); getMaxThreads()63 public int getMaxThreads(); setMinThreads(int threads)64 public void setMinThreads(int threads); setMaxThreads(int threads)65 public void setMaxThreads(int threads); 66 } 67 } 68