01: /**
02: *
03: */package org.drools.concurrent;
04:
05: import org.drools.WorkingMemory;
06:
07: public class DefaultExecutorService implements ExecutorService {
08: private Thread thread;
09: private CommandExecutor executor;
10: private boolean running;
11:
12: public DefaultExecutorService() {
13:
14: }
15:
16: public void setCommandExecutor(CommandExecutor executor) {
17: this .executor = executor;
18: }
19:
20: public void startUp() {
21: this .thread = new Thread(executor);
22: this .thread.start();
23: this .running = true;
24: }
25:
26: public void shutDown() {
27: this .executor.shutdown();
28: this .running = false;
29: }
30:
31: public Future submit(Command command) {
32: if (!this.running) {
33: startUp();
34: }
35: return this.executor.submit(command);
36: }
37: }
|