-
Notifications
You must be signed in to change notification settings - Fork 155
Closed
Labels
Description
Hi everyone.
This project include example to use lazy val field. In new proposal to Scala project have changed implementation of lazy val.
/**
* In order to get thread safety, you need to put @volatile before lazy vals.
* https://dotty.epfl.ch/docs/reference/changed-features/lazy-vals-init.html
*/
@volatile lazy val xs: List[String] = List("d", "o", "t", "t", "y")
As I understood to safe thread-safe sematics we need to attach @volatile annotation to lazy val field.
Dotty/Scala3 in std have scala.annotation.threadUnsafe annotation also. Is it still actual annotation? And if it is true in wich cases we need to use this annotation. Can you please add example?
Thank you