File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\main\java\org\jvnet\hudson\test\ThreadPoolImpl.java.html

1 package org.jvnet.hudson.test;
2
3 import org.mortbay.component.AbstractLifeCycle;
4 import org.mortbay.thread.ThreadPool;
5
6 import java.util.concurrent.ExecutorService;
7 import java.util.concurrent.TimeUnit;
8
9 /**
10 * @author Kohsuke Kawaguchi
11 */
12 public class ThreadPoolImpl extends AbstractLifeCycle implements ThreadPool {
13 private final ExecutorService es;
14
15 public ThreadPoolImpl(ExecutorService es) {
16 this.es = es;
17 }
18
19 public boolean dispatch(Runnable job) {
20 if (!isRunning() || job==null)
21 return false;
22
23 es.submit(job);
24 return true;
25 }
26
27 public void join() throws InterruptedException {
28 while(!es.awaitTermination(999 * 60 * 60 * 24, TimeUnit.SECONDS))
29 ;
30 }
31
32 public int getThreads() {
33 return 999;
34 }
35
36 public int getIdleThreads() {
37 return 999;
38 }
39
40 public boolean isLowOnThreads() {
41 return false;
42 }
43
44 @Override
45 protected void doStart() throws Exception {
46 // noop
47 }
48
49 @Override
50 protected void doStop() throws Exception {
51 es.shutdown();
52 }
53 }
54