2
//... 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;

Okay, I've looked all over. I need to know how I can make this wait until it finishes retrieving a value from a database to return this.

aioobe
  • 413,195
  • 112
  • 811
  • 826
Neil Derno
  • 77
  • 2
  • 13

1 Answers1

6

You use result.get() to wait for the task to finish and to retrieve the result.

The API documentation is your friend. Here's the page describing the API of Future.

aioobe
  • 413,195
  • 112
  • 811
  • 826