Skip to content

Instantly share code, notes, and snippets.

Created November 21, 2012 00:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4122309 to your computer and use it in GitHub Desktop.
Save anonymous/4122309 to your computer and use it in GitHub Desktop.
Webbit Handler
private HttpHandler asyncCall = new HttpHandler() {
@Override
public void handleHttpRequest(final HttpRequest request, final HttpResponse response, HttpControl control) throws Exception {
log.info("handling "+request);
Thread worker = new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
getExecutor().execute(new Runnable() {
@Override
public void run() {
response.content("\"Expensive result! "+System.currentTimeMillis()/1000+"\"");
response.end();
log.info("responded to "+request);
}
});
}
});
worker.start();
log.info("returned from handler "+request);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment