Skip to content

Example usage @threadUnsafe annotation #79

@Teinnsei

Description

@Teinnsei

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions