---
title: "Discussion on \"Enabling Virtual Thread in Kotlin + Spring Boot\" | Hashnode"
description: "Discussion on \"Enabling Virtual Thread in Kotlin + Spring Boot\". Discover how to enable virtual threads in Kotlin with Spring Boot. A comprehensive guide for optimizing concurrency in modern Kotlin applications."
url: "https://hashnode.com/posts/enabling-virtual-thread-in-kotlin-spring-boot/65803f11119ea81e7199e842"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Enabling Virtual Thread in Kotlin + Spring Boot](https://jsonobject.com/enabling-virtual-thread-in-kotlin-spring-boot?utm_source=hashnode&utm_medium=feed)

Discover how to enable virtual threads in Kotlin with Spring Boot. A comprehensive guide for optimizing concurrency in modern Kotlin applications.

Dec 18, 2023 · 7 min read · jsonobject.com  
Updated Mar 26, 2024  
Read the article

-   [#virtual-thread](https://hashnode.com/tag/virtual-thread)
-   [#kotlin](https://hashnode.com/tag/kotlin)
-   [#springboot](https://hashnode.com/tag/springboot)

## Written by

[Taehyeong Lee](https://hashnode.com/@jsonobject)

@jsonobject · Seoul, Korea

  
[View profile](https://hashnode.com/@jsonobject)

Simple is best

## Responses 2

Markdown supported · ⌘↵ to post

[Jamie Cordeiro](https://hashnode.com/@JamieC1)

[Mar 26, 2024](https://hashnode.com/posts/enabling-virtual-thread-in-kotlin-spring-boot/65803f11119ea81e7199e842/comment/66026c9cc44fbc7985bec425)

Thanks for your article. But I have a question How can I adapt the @Async annotation in Spring Boot to use virtual threads instead of traditional platform threads? [PublixPassport](https://www.publix-passport.com/)

[Taehyeong Lee](https://hashnode.com/@jsonobject)

[Mar 27, 2024](https://hashnode.com/posts/enabling-virtual-thread-in-kotlin-spring-boot/65803f11119ea81e7199e842/comment/66026c9cc44fbc7985bec425#reply-660361e92899260fb67d358c)

If you specify @Async(TaskExecutionAutoConfiguration.APPLICATION\_TASK\_EXECUTOR\_BEAN\_NAME) at the method level of your spring bean, it will automatically work as a Virtual Thread. I've added that to the article :)

[Divine Threepwodd](https://hashnode.com/@divinethreepwood)

[Mar 22, 2024](https://hashnode.com/posts/enabling-virtual-thread-in-kotlin-spring-boot/65803f11119ea81e7199e842/comment/65fd4851edfb609f329fa5eb)

Hey, thanks for the report. I am just wondering why you need all these --enable-preview declarations for jdk 21 since you mentioned that this is already enabled by default in the LTS?

[Taehyeong Lee](https://hashnode.com/@jsonobject)

[Mar 25, 2024](https://hashnode.com/posts/enabling-virtual-thread-in-kotlin-spring-boot/65803f11119ea81e7199e842/comment/65fd4851edfb609f329fa5eb#reply-6600bfc07c2af3872c7e93e8)

Good point. JDK 21 wasn't out at the time of the original post, which is why there was a vestige of it in the example. As you say, the --enable-preview option is not needed in JDK 21. I've fixed the example as well. Thanks for the feedback :)
