Each time a method annotated by @Asynchronous is called by someone, it immediately returns no matter how long the method actually takes.
Each call should return a Future object, which essentially starts empty and will later have its value filled by the container when the call to the corresponding method actually ends.
For instance:
@Asynchronous public Future<String> cantstopme() { }
and then name it like this:
final Future<String> request = cantstopme();
And later, you can request the result using the Future.get () method with a specific timeout, i.e.
request.get(10, TimeUnit.SECONDS);
source share