12 |
|
* mechanics of how each task will be run, including details of thread |
13 |
|
* use, scheduling, etc. An {@code Executor} is normally used |
14 |
|
* instead of explicitly creating threads. For example, rather than |
15 |
< |
* invoking {@code new Thread(new(RunnableTask())).start()} for each |
15 |
> |
* invoking {@code new Thread(new RunnableTask()).start()} for each |
16 |
|
* of a set of tasks, you might use: |
17 |
|
* |
18 |
|
* <pre> |
52 |
|
* |
53 |
|
* <pre> {@code |
54 |
|
* class SerialExecutor implements Executor { |
55 |
< |
* final Queue<Runnable> tasks = new ArrayDeque<Runnable>(); |
55 |
> |
* final Queue<Runnable> tasks = new ArrayDeque<>(); |
56 |
|
* final Executor executor; |
57 |
|
* Runnable active; |
58 |
|
* |
61 |
|
* } |
62 |
|
* |
63 |
|
* public synchronized void execute(final Runnable r) { |
64 |
< |
* tasks.offer(new Runnable() { |
64 |
> |
* tasks.add(new Runnable() { |
65 |
|
* public void run() { |
66 |
|
* try { |
67 |
|
* r.run(); |