DevOps Articles

Curated articles, resources, tips and trends from the DevOps World.

Lambdas in Concurrency With Non-Blocking IO

5 years ago dzone.com

Summary: This is a summary of an article originally published by the source. Read the full original article here →

by We will show a simple use case of requesting a list of urls and summing the response bodies’ lengths and how the use or absence of lambdas may result in a concurrent or sequential computing .

To perform asynchronous HTTP requests in Java we may use the java 11 HttpClient, which is also available for Kotlin.

We may start by the use of the asynchronous fetch() function to perform an HTTP get request and henceforward we may use the await to get the fulfilled value of the resulting promise.

To that end we need to use a coroutine builder that will run the given lambda in a new coroutine and returns a promise of its execution.

Made with pure grit © 2024 Jetpack Labs Inc. All rights reserved. www.jetpacklabs.com