Skip to content

Instantly share code, notes, and snippets.

@wspeirs
Created January 8, 2014 22:46
Show Gist options
  • Save wspeirs/8326003 to your computer and use it in GitHub Desktop.
Save wspeirs/8326003 to your computer and use it in GitHub Desktop.
AsyncExecutor asyncRun = new AsyncExecutor(Executors.newFixedThreadPool(5));
try
{
// Setup the UpdateExecutor
UpdateExecutor executor = runner.update("UPDATE Person SET height=:height WHERE name=:name")
.bind(":height", 2.05)
.bind("name", "John Doe");
// Returns a Future for the update call
Future<Integer> callable = asyncRun.execute(executor);
} catch(SQLException sqle) {
// Handle it
}
// Sometime later (or in another thread)
try
{
// Get the result of the update
Integer updates = callable.get();
} catch(InterruptedException ie) {
// Handle it
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment