MENU

Fun & Interesting

CPU Cache Coherence + Java Concurrency

Jakob Jenkov 21,891 4 years ago
Video Not Working? Fix It Now

CPU cache coherence impacts how the Java concurrency features such as the Java volatile and synchronized block features work. This video explains how Java volatile and synchronized "interact" with the CPU cache coherence. Basically, what happens is that when a Java thread writes to a Java volatile variable, or a Java thread exits a synchronized block, the Java VM flushes any thread visible variables from CPU registers to main memory. The hardware may choose only to flush the variables into the CPU cache, and then rely on its Cache coherence strategy to make sure those variables are still visibles to other CPUs. Eventually the hardware will flush the variables to main RAM - when the CPU cache lines containing the variables are needed for other data. Java Concurrency + Cache Coherence - text: https://jenkov.com/tutorials/java-concurrency/cache-coherence-in-java-concurrency.html Java Concurrency Tutorials - text: https://jenkov.com/tutorials/java-concurrency/index.html Java Concurrency Playlist: https://www.youtube.com/playlist?list=PLL8woMHwr36EDxjUoCzboZjedsnhLP1j4

Comment