Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardJavavolatile semanticsSingle-choice MCQ

A `volatile` array field is published. One thread does `arr[5] = 42;` and another reads `arr[5]`. What does the volatile modifier on the field actually guarantee here?

volatile int[] arr = new int[10]; // Thread A // Thread B arr[5] = 42; int v = arr[5];