I’m working to make a crawler in Java. I made a single-threaded crawler to visit a single page and fetch all links on that page. Now I want to make it multi-threaded but facing difficulties. In the very beginning I start with single link of the page and crawl through all the links in it and Now I want to
Tag: executorservice
Naming threads and thread-pools of ExecutorService
Let’s say I have an application that utilizes the Executor framework as such When I run this application in the debugger, a thread is created with the following (default) name: Thread[pool-1-thread-1]. As you can see, this isn’t terribly useful and as far as I can tell, the Executor framework does not provide an easy way to name the created threads
Impossible to make a cached thread pool with a size limit?
It seems to be impossible to make a cached thread pool with a limit to the number of threads that it can create. Here is how static Executors.newCachedThreadPool is implemented in the standard Java library: So, using that template to go on to create a fixed sized cached thread pool: Now if you use this and submit 3 tasks, everything
Executors.newCachedThreadPool() versus Executors.newFixedThreadPool()
newCachedThreadPool() versus newFixedThreadPool() When should I use one or the other? Which strategy is better in terms of resource utilization? Answer I think the docs explain the difference and usage of these two functions pretty well: newFixedThreadPool Creates a thread pool that reuses a fixed number of threads operating off a shared unbounded queue. At any point, at most nThreads