Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Wiki Markup
Task-specific recovery or clean-up actions can be performed by overriding the {{afterExecute()}} hook of the {{java.util.concurrent.ThreadPoolExecutor}} class. This hook is called either when a task concludes successfully by executing all statements in its {{run()}} method or when the task halts because of an exception. Some implementations may fail to catch {{java.lang.Error}}. (See [Bug ID 6450211|http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6450211] for more information \[[SDN 2008|AA. Bibliography#SDNReferences#SDN 08]\].)  When using this approach, substitute the executor service with a custom {{ThreadPoolExecutor}} that overrides the {{afterExecute()}} hook:

...

Wiki Markup
The {{ExecutorService.submit()}} method can be used (in place of the {{execute()}} method) to submit a task to a thread pool and obtain a {{Future}} object. When the task is submitted via  {{ExecutorService.submit()}}, thrown exceptions never reach the uncaught exception handler because the thrown exception is considered to be part of the return status and is consequently wrapped in an {{ExecutionException}} and rethrown by {{Future.get()}} \[[Goetz 2006|AA. Bibliography#GoetzReferences#Goetz 06]\].

Compliant Solution (Future<V> and submit())

...

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="940e364c6c224af8-b24ead5f-4a0f4611-8ebc836e-e1e80b15b830ee87497f3029"><ac:plain-text-body><![CDATA[

[[API 2006

AA. Bibliography#API References#API 06]]

Interfaces ExecutorService, ThreadFactory; class Thread

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="3b0d4fc1ca5baa7c-5035ec6b-42b14630-8b7f909e-92b44fd6bf841f443b2af2b3"><ac:plain-text-body><![CDATA[

[[Goetz 2006

AA. Bibliography#Goetz References#Goetz 06]]

Chapter 7.3, Handling Abnormal Thread Termination

]]></ac:plain-text-body></ac:structured-macro>

...