Java Reference
In-Depth Information
Writing such an Executor is trivial, as shown in ThreadPerTaskExecutor in Listing
6.5 .
Listing 6.5. Executor that Starts a New Thread for Each Task.
Similarly, it is also easy to write an Executor that would make TaskExecutionWe-
bServer behave like the single-threaded version, executing each task synchronously before
returning from execute , as shown in WithinThreadExecutor in Listing 6.6 .
6.2.2. Execution Policies
The value of decoupling submission from execution is that it lets you easily specify, and sub-
sequently change without great difficulty, the execution policy for a given class of tasks. An
execution policy specifies the “what, where, when, and how” of task execution, including:
Listing 6.6. Executor that Executes Tasks Synchronously in the Calling Thread.
In what thread will tasks be executed?
In what order should tasks be executed (FIFO, LIFO, priority order)?
How many tasks may execute concurrently?
How many tasks may be queued pending execution?
Search WWH ::




Custom Search