advancedMultithreading & Concurrency358 of 436
Visibility & volatile — CPU caches, stale reads, and how volatile flush/invalidate works
Tests whether you understand volatile forces a write to flush from the writing CPU's cache (store barrier) and forces a read to invalidate and re-fetch from main memory (load barrier), rather than just treating it as a vague 'makes it thread-safe' keyword.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a responseNext Step
←PreviousContinue to What is lock escalation? Can excessive locking become a scalability bottleneck?→
← Back to all Core Java questions