Docs API
Scala 3/Reference/Other New Features/The @threadUnsafe annotation
Edit this page on GitHub

The @threadUnsafe annotation

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

In this article

AltStyle によって変換されたページ (->オリジナル) /