使用HtmlUnit的并发请求

时间:2014-10-25 06:07:58

标签: groovy concurrency htmlunit concurrent-programming gpars

这是我的代码:

def search = {item->
    def url = "http://localhost:8080/search/"+item
    println 'url='+ url
    page = webClient.getPage(url);
    println 'pageURL=' + page.url
}

GParsPool.withPool(5) {
    searchList.each  {item-> search.callAsync(item) }
}

打印出来:

url=http://localhost:8080/search/1
url=http://localhost:8080/search/3
url=http://localhost:8080/search/5
url=http://localhost:8080/search/4
url=http://localhost:8080/search/2
pageURL=http://localhost:8080/search/5
pageURL=http://localhost:8080/search/5
pageURL=http://localhost:8080/search/5
pageURL=http://localhost:8080/search/5
url=http://localhost:8080/search/7
url=http://localhost:8080/search/6
pageURL=http://localhost:8080/search/5
url=http://localhost:8080/search/9
url=http://localhost:8080/search/8
url=http://localhost:8080/search/10
pageURL=http://localhost:8080/search/10
pageURL=http://localhost:8080/search/8
pageURL=http://localhost:8080/search/6
pageURL=http://localhost:8080/search/6
pageURL=http://localhost:8080/search/6

为什么pageURL与网址不匹配?对项目5有多个请求,没有对项目1的请求。

0 个答案:

没有答案