I am new to groovy / grails.
How to implement a thread for this code. It had 2500 URLs, and it took several hours to check each URL.
so I decided to implement multithreading for this:
Here is my sample code:
def urls = [
"http://www.wordpress.com",
"http://67.192.103.225/QRA.Public/" ,
"http://www.subaru.com",
"http://baldwinfilter.com/products/start.html"
]
def up = urls.collect { ur ->
try {
def url = new URL(ur)
def connection = url.openConnection()
if (connection.responseCode == 200) {
return true
} else {
return false
}
} catch (Exception e) {
return false
}
}
For this code, I need to implement multithreading .
Can anyone suggest me a code.
thanks in advance,
shri.
source
share