This talk introduces Virtual Threads and Structured Concurrency and explains their benefits and shortcomings. It compares Structured Concurrency API with CompletableFuture API by live coding multiple examples with both of these APIs.
Virtual threads are lightweight user threads, enabling Java applications to produce thousand (or even million) times more threads. Also, they are super-efficient as they don't block their 'carrier' threads. These two characteristics of virtual threads enable Structured Concurrency.
With structured concurrency, we can let each business-task be executed by a separate virtual thread and structure these virtual threads in any logical way that we want. It provides us with control structures for managing our virtual threads and simplifies applications that use concurrency.
A big part of the talk is live coding where multiple examples are first implemented with CompletableFuture and then with Structured Concurrency API. For each example, these two implementations are then compared. These examples highlight that CompletableFuture’s reactive-like API relies on callbacks whereas Structured Concurrency puts forward an imperative-like API which is easier to read and reason. Also error handling with Structured Concurrency is more explicit as it uses checked exceptions.
All in all, this talk introduces virtual threads and structured concurrency to the audience and explains why one should seriously consider using it.
➜ Abonniere JAVAPRO und verpasse keine News:
bit.ly/KZitem...
▬ Über uns: ▬
JAVAPRO ist das Magazin für professionelle Java-Entwicklung in der Praxis.
Über das Magazin hinaus ist JAVAPRO Veranstalter der jährlich stattfindenden Entwickler-Konferenz JCON. Auf der JCON stehen Core Java, Enterprise Java, Microservices, APIs und Frameworks im Fokus.
Auf diesem Kanal finden sich Interviews, Sessions, Tipps & Tricks und alles, was das (Java)-Entwickler-Herz begehrt.
➜ Jetzt kostenlos Magazin anfordern:
javapro.io
▬ Folge uns auf Social Media: ▬
Twitter: / javapromagazin
Facebook: / javapromag
➜ Danke fürs Abo & fürs Zusehen!
Негізгі бет Structured Concurrency in Java - The What and the Why | Balkrishna Rawool (EN)
Пікірлер