Java Reference
In-Depth Information
Listing 7.21. ExecutorService that Keeps Track of Cancelled Tasks After Shutdown.
WebCrawler in Listing 7.22 shows an application of TrackingExecutor . The work of
a web crawler is often unbounded, so if a crawler must be shut down we might want to save
its state so it can be restarted later. CrawlTask provides a getPage method that identifies
what page it is working on. When the crawler is shut down, both the tasks that did not start
and those that were cancelled are scanned and their URLs recorded, so that page-crawling
tasks for those URLs can be added to the queue when the crawler restarts.
Search WWH ::




Custom Search