You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit adds a new section in the Spring Boot reference
documentation to mention potential throughput limitations with Java
virtual threads support.
This section links to the official Java documentation which expands much
more on this matter.
Closesgh-38883
Copy file name to clipboardExpand all lines: spring-boot-project/spring-boot-docs/src/docs/asciidoc/features/spring-application.adoc
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -384,10 +384,14 @@ Spring Boot can also be configured to expose a {spring-boot-actuator-restapi-doc
384
384
=== Virtual threads
385
385
If you're running on Java 21 or up, you can enable virtual threads by setting the property configprop:spring.threads.virtual.enabled[] to `true`.
386
386
387
+
Before turning on this option for your application, you should consider https://docs.oracle.com/en/java/javase/21/core/virtual-threads.html[reading the official Java virtual threads documentation].
388
+
In some cases, applications can experience lower throughput because of "Pinned Virtual Threads"; this page also explains how to detect such cases with JDK Flight Recorder or the `jcmd` CLI.
389
+
387
390
WARNING: One side effect of virtual threads is that these threads are daemon threads.
388
391
A JVM will exit if there are no non-daemon threads.
389
392
This behavior can be a problem when you rely on, e.g. `@Scheduled` beans to keep your application alive.
390
393
If you use virtual threads, the scheduler thread is a virtual thread and therefore a daemon thread and won't keep the JVM alive.
391
394
This does not only affect scheduling, but can be the case with other technologies, too!
392
395
To keep the JVM running in all cases, it is recommended to set the property configprop:spring.main.keep-alive[] to `true`.
393
396
This ensures that the JVM is kept alive, even if all threads are virtual threads.
0 commit comments