ExecutorService executorService = Executors.newFixedThreadPool(2);
WebRequest longTask = new WebRequest(IntrospectServlet.MODE_LONG_TASK, contextPath, cid, jsessionid);
WebRequest busyRequest = new WebRequest(IntrospectServlet.MODE_BUSY_REQUEST, contextPath, cid, jsessionid);
final Future<String> longTaskFuture = executorService.submit(longTask);
Timer timer = Timer.startNew(100l);
final Future<String> busyRequestFuture = executorService.submit(busyRequest);
timer.setSleepInterval(100l).setDelay(10, TimeUnit.SECONDS).addStopCondition(new StopCondition() {
@Override
public boolean isSatisfied() {
return longTaskFuture.isDone() || busyRequestFuture.isDone();
}
}).start();