It is possible to make multiple requests by using multithreading.
For managing concurrency you can use ExecutorService
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/Execut...
Example:
ExecutorService executor = Executors.newFixedThreadPool(size);
Future response1 = executor.submit(new GetComments(offset));
Future response2 = executor.submit(new GetComments(offset));
.....
class GetComments implements Callable {
private String url;
public ParralelCommentsRequest(int offset) {
this.url = ....
}
@Override
public InputStream call() throws Exception {
return new URL(url).openStream();
}
}
The method submit extends base method Executor.execute(java.lang.Runnable) by creating and returning a Future that can be used to cancel execution and/or wait for completion.
The class GetComments implements Callable which is similar to Runnable, but it can return a result.