groovy multithreading

Posted by srinath on Stack Overflow See other posts from Stack Overflow or by srinath
Published on 2010-04-06T09:22:14Z Indexed on 2010/04/06 9:23 UTC
Read the original article Hit count: 629

Filed under:
|
|

Hi, I'm newbie to groovy/grails.
How to implement thread for this code . Had 2500 urls and this was taking hours of time for checking each url.
so i decided to implement multi-thread 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 multi-threading .
Could any one please suggest me the code.

thanks in advance,
sri.

© Stack Overflow or respective owner

Related posts about groovy

Related posts about grails