19 - Introduction to Asynchronous Method Invocation


Asynchronous method invocation is the process of executing service methods in the background for the purposes of increasing response time, doing background tasks and handing long running tasks.

The difference between normal (synchronous) method invocation and asynchronous method invocation is that in case of asynchronous method,  once the method gets invoked, the control returns immediately to the main thread regardless of the execution time of the invoked method. But in case of  the synchronous invocation,  the main thread will wait till the execution of the invoked method gets finished and then returns the control to the main thread, with main here we mean the thread that triggered the invocation process.

Also, in synchronous invocation, the main thread can retrieve the return value from the invoked method, but in asynchronous invocation the method can only return a value of Future<T> object that can be used to monitor the execution of the invoked method and to retrieve/cancel the invocation.

Like us on Facebook