# Blocking vs Asynchronous REST

This demo calls the Google Maps WebService API to find places matching each of the search criteria passed on the query string.

The rest API is called both synchronously and asynchronously for comparison. The time the request thread is held by the servlet is displayed in red for both.

Using a combination of the asynchronous servlet API and an asynchronous http client, the server is able to release the request thread back to the thread pool (shown in green) while waiting for the response from the Google service. The thread can be reused to handle other requests during the wait, which greatly reduces the number of threads required and server resources.

Synchronous
Asynchronous
Effects of Synchronous Vs Asynchronous processing