src/share/classes/java/util/concurrent/AbstractExecutorService.java
Print this page
@@ -49,24 +49,24 @@
* <tt>FutureTask</tt>.
*
* <p> <b>Extension example</b>. Here is a sketch of a class
* that customizes {@link ThreadPoolExecutor} to use
* a <tt>CustomTask</tt> class instead of the default <tt>FutureTask</tt>:
- * <pre>
+ * <pre> {@code
* public class CustomThreadPoolExecutor extends ThreadPoolExecutor {
*
- * static class CustomTask<V> implements RunnableFuture<V> {...}
+ * static class CustomTask<V> implements RunnableFuture<V> {...}
*
- * protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) {
- * return new CustomTask<V>(c);
+ * protected <V> RunnableFuture<V> newTaskFor(Callable<V> c) {
+ * return new CustomTask<V>(c);
* }
- * protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) {
- * return new CustomTask<V>(r, v);
+ * protected <V> RunnableFuture<V> newTaskFor(Runnable r, V v) {
+ * return new CustomTask<V>(r, v);
* }
* // ... add constructors, etc.
- * }
- * </pre>
+ * }}</pre>
+ *
* @since 1.5
* @author Doug Lea
*/
public abstract class AbstractExecutorService implements ExecutorService {
@@ -104,11 +104,11 @@
* @throws RejectedExecutionException {@inheritDoc}
* @throws NullPointerException {@inheritDoc}
*/
public Future<?> submit(Runnable task) {
if (task == null) throw new NullPointerException();
- RunnableFuture<Object> ftask = newTaskFor(task, null);
+ RunnableFuture<Void> ftask = newTaskFor(task, null);
execute(ftask);
return ftask;
}
/**
@@ -156,11 +156,11 @@
try {
// Record exceptions so that if we fail to obtain any
// result, we can throw the last exception we got.
ExecutionException ee = null;
- long lastTime = (timed)? System.nanoTime() : 0;
+ long lastTime = timed ? System.nanoTime() : 0;
Iterator<? extends Callable<T>> it = tasks.iterator();
// Start one task for sure; the rest incrementally
futures.add(ecs.submit(it.next()));
--ntasks;
@@ -189,12 +189,10 @@
}
if (f != null) {
--active;
try {
return f.get();
- } catch (InterruptedException ie) {
- throw ie;
} catch (ExecutionException eex) {
ee = eex;
} catch (RuntimeException rex) {
ee = new ExecutionException(rex);
}