Skip to content

execute multiple select queries asynchronously and consolidate results #981

Closed Answered by lvca
vic0824 asked this question in Q&A
Discussion options

You must be logged in to vote

@vic0824 you could use the waitCompletion(), but it'd wait for any other pending requests, so if you're other things running it's not the ideal.

You could use a CountDownLatch to do that. This is an example (not tested. checkout for misspelling):

CountDownLatch counter = new CountDownLatch(3);

Resultset resultset1 = database.async().query("sql", "select from X", new AsyncResultsetCallback() {
  public void onComplete() { counter.countDown();  }
});

Resultset resultset2 = database.async().query("sql", "select from Y", new AsyncResultsetCallback() {
  public void onComplete() { counter.countDown();  }
});

Resultset resultset3 = database.async().query("sql", "select from Z", new AsyncResu…

Replies: 4 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by vic0824
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
6 replies
@vic0824
Comment options

@lvca
Comment options

@lvca
Comment options

@lvca
Comment options

@lvca
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants