I have a class that I use for testing links. I pass the links to the class using a for loop. Inside my class I use httpclient to open the connection to the link. This can happen several thousand times. After a while I start to get timeouts, I presume this is to do with creating so many httpclients.
My question is, whats the best way to go about managing this(I’m a beginner fyi). Should I be closing connections, only using one httpclient etc.
Before the end of each loop you should do that
Webpage.close();.Another idea is to create the object outside the loops, and instantiate them inside. Something like: