View Javadoc

1   //
2   //  ========================================================================
3   //  Copyright (c) 1995-2013 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  import org.eclipse.jetty.util.component.LifeCycle;
26  
27  /* ------------------------------------------------------------ */
28  /** ThreadPool.
29   * 
30   *
31   */
32  @ManagedObject("Pool of Threads")
33  public interface ThreadPool extends Executor
34  {
35      /* ------------------------------------------------------------ */
36      /** 
37       * @deprecated use {@link Executor#execute(Runnable)}
38       */
39      @Deprecated
40      public abstract boolean dispatch(Runnable job);
41  
42      /* ------------------------------------------------------------ */
43      /**
44       * Blocks until the thread pool is {@link LifeCycle#stop stopped}.
45       */
46      public void join() throws InterruptedException;
47  
48      /* ------------------------------------------------------------ */
49      /**
50       * @return The total number of threads currently in the pool
51       */
52      @ManagedAttribute("number of threads in pool")
53      public int getThreads();
54  
55      /* ------------------------------------------------------------ */
56      /**
57       * @return The number of idle threads in the pool
58       */
59      @ManagedAttribute("number of idle threads in pool")
60      public int getIdleThreads();
61      
62      /* ------------------------------------------------------------ */
63      /**
64       * @return True if the pool is low on threads
65       */
66      @ManagedAttribute("indicates the pool is low on available threads")
67      public boolean isLowOnThreads();
68      
69  
70      /* ------------------------------------------------------------ */
71      /* ------------------------------------------------------------ */
72      public interface SizedThreadPool extends ThreadPool
73      {
74          public int getMinThreads();
75          public int getMaxThreads();
76          public void setMinThreads(int threads);
77          public void setMaxThreads(int threads);
78      }
79  }