1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
...
boolean bResult = false;
int iTimeout = 10000;
final List<String> taskParameters = params;
try {
// create new task
theTask = new FutureTask<Object>(new Runnable() {
public void run() {
try {
boolean bResultTask = Report.execute(params);
} catch(Exception e) {
...
}
}
}, null);
// start task in a new thread
new Thread(theTask).start();
// wait for the execution to finish, timeout after 10 secs theTask.get(iTimeout, TimeUnit.MILLISECONDS);
} catch (TimeoutException e) {
System.out.println("TimeoutException");
throw new TimeoutException();
}
...
if(bResult) {
...
} |
Partager