8 |
|
|
9 |
|
|
10 |
|
/** |
11 |
< |
* A {@link CompletionService} that uses a supplied {@link ExecutorService} |
11 |
> |
* A {@link CompletionService} that uses a supplied {@link Executor} |
12 |
|
* to execute tasks. |
13 |
|
*/ |
14 |
|
public class ExecutorCompletionService<V> implements CompletionService<V> { |
15 |
< |
private final ExecutorService executor; |
15 |
> |
private final Executor executor; |
16 |
|
private final LinkedBlockingQueue<Future<V>> cq = |
17 |
|
new LinkedBlockingQueue<Future<V>>(); |
18 |
|
|
31 |
|
* executor should be dedicated for use by this service |
32 |
|
8 @throws NullPointerException if executor is null |
33 |
|
*/ |
34 |
< |
public ExecutorCompletionService(ExecutorService executor) { |
34 |
> |
public ExecutorCompletionService(Executor executor) { |
35 |
|
if (executor == null) |
36 |
|
throw new NullPointerException(); |
37 |
|
this.executor = executor; |
39 |
|
|
40 |
|
|
41 |
|
/** |
42 |
< |
* Return the {@link ExecutorService} used for base |
42 |
> |
* Return the {@link Executor} used for base |
43 |
|
* task execution. This may for example be used to shut |
44 |
|
* down the service. |
45 |
|
* @return the executor |
46 |
|
*/ |
47 |
< |
public ExecutorService getExecutor() { |
47 |
> |
public Executor getExecutor() { |
48 |
|
return executor; |
49 |
|
} |
50 |
|
|