1
2
3
4
5 package org.neo.swarm.util.threads;
6
7
8 /***
9 * Represents a generic threadpool implementation
10 * Exposes a set of thread related parameters to allow the pool to be managed.
11 * @author navery
12 */
13 public interface ThreadPool {
14 /***
15 * Execute a Runnable impl using an internal thread
16 * @param unitOfWork
17 * @throws InterruptedException
18 */
19 public void execute(Runnable unitOfWork) throws InterruptedException;
20
21 /***
22 * The max available pool size.
23 * @return
24 */
25 public int getMaximumPoolSize();
26
27
28 /***
29 * Minimum available pool size.
30 * @return
31 */
32 public int getMinimumPoolSize();
33
34 /***
35 * Current number of threads in use.
36 * @return
37 */
38 public int getPoolSize();
39
40 /***
41 * Set max thread limit, must also support dynamic
42 * resizing of the pool.
43 * @param poolSize
44 */
45 public void setMaximumPoolSize(int poolSize);
46
47 /***
48 * Set min thread limit.
49 * @param poolSize
50 */
51 public void setMinimumPoolSize(int poolSize);
52
53 /***
54 * Timeout of 0 kills all threads, pending or executing,
55 * Greater values will allow the incoming queue to be processed, however blocked threads
56 * may cause an issue. Oswego allows a Blocker handler to be used.
57 * @param timeout
58 */
59 void shutdown(int timeout);
60
61 }