We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3b09fcc commit 7a8c397Copy full SHA for 7a8c397
src/main/java/com/fishercoder/solutions/secondthousand/_1242.java
@@ -20,8 +20,10 @@ public List crawl(String startUrl, HtmlParser htmlParser) {
20
Set<String> visited = new HashSet<>();
21
22
Queue<Future> tasks = new LinkedList<>();
23
+ //create a thread pool to crawling the URLs
24
ExecutorService executorService = Executors.newFixedThreadPool(4, r -> {
25
Thread t = new Thread(r);
26
+ //LeetCode doesn't allow executor.shutdown(), so use daemon threads to let the program shutdown, otherwise TLE.
27
t.setDaemon(true);
28
return t;
29
});
0 commit comments