Tehničko veleučilište u Zagrebu · Zagreb

Comparison of Structured Concurrency Constructs in Java and Kotlin – Virtual Threads and Coroutines

izvorni znanstveni rad

izvorni znanstveni rad

Comparison of Structured Concurrency Constructs in Java and Kotlin – Virtual Threads and Coroutines

Vrsta prilog sa skupa (u zborniku)
Tip izvorni znanstveni rad
Godina 2022
Nadređena publikacija Proceedings of the 45th International Convention for Information and Communication Technology, Electronics and Microelectronics - MIPRO 2022
Stranice str. 1684-1689
ISSN 1847-3938
EISSN 1847-3946
Status objavljeno

Sažetak

Ubiquitous multi-core processors with a significant increase in computing power resulted in an omnipresent expansion of concurrent server applications. However, modern multithreaded applications exposed a substantial number of efficiency-related challenges. Consequently, lightweight structured concurrency constructs emerged in various multithreaded applications, as the traditional heavyweight threads model is expensive in regards to memory due to its high dependency on OS kernel threads. Modern programming languages such as Kotlin and Java are both built on the Java Virtual Machine (JVM) and are commonly used in mobile application development and server-side applications, offering, by default, the traditional threads approach. However, Kotlin also includes support for a lightweight concurrency model with coroutines, while Java's virtual threads, announced in the OpenJDK's Project Loom, are still experimental. Such contemporary concurrency implementations are primarily enabling an increase in application performance and efficiency. This paper presents an overview of different approaches to structured concurrency and explores their implementation in programming languages Java and Kotlin. It provides a comparative analysis of traditional threads with coroutines in Kotlin and virtual threads in Java. Based on the conducted testing using benchmarks, we analyzed their performance, described implementation differences, and explored their utilization possibilities and adaptation to real-world use-case scenarios.

Ključne riječi

Concurrent Programing, Virtual Threads, Coroutines, Structured Concurrency, Java, Kotlin