Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavafinal-field publicationSingle-choice MCQ

This object is published via a data race (plain field, no final, no volatile, no synchronization). A reader thread observes p != null. Under the JMM, what is the strongest correct statement about the reader seeing x == 7?

class P { int x; P(){ x = 7; } } class Box { P p; } // plain field // writer: box.p = new P(); // reader: if (box.p != null) use(box.p.x);