I am trying to make an asynchronous call from within my (Spring MVC based) Controller.
I am using the following snippet:
FutureTask<Object> runnableTask = new FutureTask<Object>(
new Runnable() {
public void run() {
// do something
}
}, null);
runnableTask.run();
However, no matter what, this is not executed asynchronously, i.e., my Controller does not return back the response (to the view) until the above task completes. Am I missing something or is there an alternate way to do so?
You need an executor to do that:
But spring already has that (docs) – just make a method and annotate it with
@Async(and have<task:annotation-driven />in the xml)