The @threadUnsafe annotation (original) (raw)
Scala 3
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL
A new annotation @threadUnsafe can be used on a field which defines a lazy val
. When this annotation is used, the initialization of the lazy val will use a faster mechanism which is not thread-safe.
Example
import scala.annotation.threadUnsafe
class Hello:
@threadUnsafe lazy val x: Int = 1
Contributors to this page
Generated with
Copyright (c) 2002-2025, LAMP/EPFL
Copyright (c) 2002-2025, LAMP/EPFL