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="9403ab0e2edcfbb6-ba92809f-4e1b4407-b3b1a1aa-2ce63f953c4c525548c23699"><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="07aa0c8de09b252f-4035547c-4fc04f2c-b181b22f-2b91efc0a0ff79aea2790739"><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>

...