Reactive Systems in Java by Clement Escoffier & Ken Finnigan

Reactive Systems in Java by Clement Escoffier & Ken Finnigan

Author:Clement Escoffier & Ken Finnigan [Clement Escoffier]
Language: eng
Format: epub, pdf
Publisher: O'Reilly Media, Inc.
Published: 2021-12-24T16:00:00+00:00


Example 5-2. Example of asynchronous code

service.greeting("Luke", greeting -> { System.out.println(greeting); });

In this code snippet, we pass a continuation implemented using a callback, i.e. a function invoked with the received result. It embraces well the event-driven nature of this code: on result, call that function. With this asynchronous model, we release the I/O thread. When the response is received, it calls the function with that response and continues the execution. During that time, this I/O thread can be used to handle more requests (Figure 5-2).



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.