public boolean checkInBackground() {
ExecutorService pool = Executors.newFixedThreadPool(1);
Callablecallable = new Callable () {
@Override
public Boolean call() throws Exception {
check();
return Boolean.TRUE;
}
};
final Futurefuture = pool.submit(callable);
pool.shutdown();
Boolean bool = Boolean.FALSE;
try {
bool = future.get(1, TimeUnit.SECONDS);
} catch (Exception e) {
future.cancel(true);
bool = Boolean.FALSE;
}
return bool;
}
public boolean check() {
//long running task
return false;
}
No comments:
Post a Comment