UPDATE: OOPS, as Vasil pointed out, the question is a copy of another thread, and as it happens, so is this answer.
I took this class:
class Foo {
lazy val test = "hi"
}
Compiled and decompiled (with jd-gui):
public class Foo
implements ScalaObject
{
private String test;
public volatile int bitmap$0;
public String test()
{
if (
(this.bitmap$0 & 0x1) == 0);
synchronized (this)
{
if (
(this.bitmap$0 & 0x1) == 0) {
this.test = "hi"; this.bitmap$0 |= 1; } return this.test;
}
}
}
As you can see it is using the double check paradigm with a volatile variable. So I think it is safe