volatile in Java
Guarantees visibility of writes to other threads (and ordering), but not atomicity.
Intermediate
Good for stop flags: volatile boolean running = true;. count++ on a volatile is still a race.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.