//... Some annoying getter
ExecutorService es = Executors.newSingleThreadExecutor();
Future<Integer> result = es.submit(new Callable<Integer>() {
public Integer call() throws Exception {
//Get some value from the SQL database.
}
});
return result;
好的,我看了一遍。我需要知道如何让它等待,直到它完成从数据库中检索一个值来返回它。