Asynchronous
Asynchronous means that the requestor gets the response immediately, but the result is not there. Instead, the requestor receives an object with methods that allow us to check whether the result is ready. The requestor calls this method periodically, and, when the result is ready, retrieves it using another method on the same object.
The advantage of such a solution is that the requestor can do other things while waiting. For example, in Chapter 11, JVM Processes and Garbage Collection, we demonstrated how a child thread can be created. So, the main thread can create a child thread that sends a non-asynchronous (also called blocking) request, and waits for its return, doing nothing. The main thread, meanwhile, can continue executing ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access