src/share/classes/java/util/concurrent/Executor.java

Print this page

        

*** 77,89 **** * Many <tt>Executor</tt> implementations impose some sort of * limitation on how and when tasks are scheduled. The executor below * serializes the submission of tasks to a second executor, * illustrating a composite executor. * ! * <pre> * class SerialExecutor implements Executor { ! * final Queue&lt;Runnable&gt; tasks = new ArrayDeque&lt;Runnable&gt;(); * final Executor executor; * Runnable active; * * SerialExecutor(Executor executor) { * this.executor = executor; --- 77,89 ---- * Many <tt>Executor</tt> implementations impose some sort of * limitation on how and when tasks are scheduled. The executor below * serializes the submission of tasks to a second executor, * illustrating a composite executor. * ! * <pre> {@code * class SerialExecutor implements Executor { ! * final Queue<Runnable> tasks = new ArrayDeque<Runnable>(); * final Executor executor; * Runnable active; * * SerialExecutor(Executor executor) { * this.executor = executor;
*** 107,117 **** * protected synchronized void scheduleNext() { * if ((active = tasks.poll()) != null) { * executor.execute(active); * } * } ! * }</pre> * * The <tt>Executor</tt> implementations provided in this package * implement {@link ExecutorService}, which is a more extensive * interface. The {@link ThreadPoolExecutor} class provides an * extensible thread pool implementation. The {@link Executors} class --- 107,117 ---- * protected synchronized void scheduleNext() { * if ((active = tasks.poll()) != null) { * executor.execute(active); * } * } ! * }}</pre> * * The <tt>Executor</tt> implementations provided in this package * implement {@link ExecutorService}, which is a more extensive * interface. The {@link ThreadPoolExecutor} class provides an * extensible thread pool implementation. The {@link Executors} class