Skip to content

Commit

Permalink
update release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
puredanger committed Oct 21, 2023
1 parent b8ea361 commit 4f6857d
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions content/news/2023/10/20/clojure-1-12-alpha5.doc
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ Alex Miller

Clojure 1.12.0-alpha5 is now available and we encourage you to try it and give us your feedback!

== Avoid user code with I/O under synchronized blocks

Java 21 LTS introduced virtual threads (aka Project Loom). Virtual threads may be paused and resumed and cooperate with many blocking operations in the JDK - I/O, ReentrantLock, etc. However, Java 21 does not allow pausing of synchronization on object monitors (synchronized) and will thus "pin" the virtual thread to a carrier thread if blocking while synchronized.

This release modifies `lazy-seq` and `delay` to use ReentrantLock instead of synchronized to avoid this issue.
== Use locks instead of synchronized blocks around user code in lazy-seq and delay

Clojure users want to use virtual threads on JDK 21. Prior to 1.12, Clojure lazy-seqs and delays, in order to enforce run-once behavior, ran user code under synchronized blocks, which don't participate in cooperative blocking. Thus if that code did e.g. blocking I/O it would pin a real thread. JDK 21 may emit the following warning for this <actual warning>. To avoid this pinning, in 1.12 we've changed lazy-seqs and delay to use locks instead of synchronized blocks.

0 comments on commit 4f6857d

Please sign in to comment.