vendredi 29 juillet 2016

Java 8 volatile primitive class members should be initialized explicitlyin the constructor? [on hold]

I have following code:

class A{}

class B extends A {
    volatile boolean flag=false;
    B(){}
}

When I create a new instance of B using new B(), the flag value is set to true. But if I explicitly set flag = false in the constructor, then the flag value is set properly to false. Is this a bug in Java 8 ?

Aucun commentaire:

Enregistrer un commentaire