I’m getting the following error:
Could not find matching constructor for:
org.crawler.CrawlerUtils$fetch(org.series.crawler.site.SubSiteA).
I’m trying to use threads. I used threads only one time, and I’m trying to do the same that I did in the other project.
I have:
Class CrawlerUtils {
public static void crawlSites(List<Site> sites) {
def pool = Executors.newFixedThreadPool(MAX_THREADS)
def ecs = new ExecutorCompletionService<Void>(pool);
sites.each { ecs.submit(new fetch(it), Void) }
sites.each { ecs.take().get() }
pool.shutdown()
}
class fetch implements Runnable {
Site site
fetch(Site site) {
this.site = site
}
public void run() {
site.parse()
}
}
}
I tried these (uglies) approaches:
- Create an Interface (using ISite site instead Site site inside fetch constructor)
- Put a constructor in each subclass inside fetch class
- Put a constructor inside each subclass that calls to super()
Any idea?
As
crawlSitesis static the classFetch(should have a capital letter to follow any form of common naming scheme) needs to be static too.I’d use GPars though… Looks at this section of the guide
You should be able to do: