Java Reference
In-Depth Information
block waiting for it to be set. On the first call to setValue , the solution is updated and the
CountDownLatch is decremented, releasing the main solver thread from getValue .
The first thread to find a solution also shuts down the Executor , to prevent new tasks from
being accepted. To avoid having to deal with RejectedExecutionException , the re-
jected execution handler should be set to discard submitted tasks. Then, all unfinished tasks
eventually run to completion and any subsequent attempts to execute new tasks fail silently,
allowing the executor to terminate. (If the tasks took longer to run, we might want to interrupt
them instead of letting them finish.)
Search WWH ::




Custom Search