3 ms·
Garbage collectors (and various other parts of the JVM) use similar tricks to coordinate threads without using memory barriers. The compiler just inserts TEST i
by the8472 11y ago
Garbage collectors (and various other parts of the JVM) use similar tricks to coordinate threads without using memory barriers. The compiler just inserts TEST instructions to some fixed memory address in strategic places in the code.
When the garbage collector needs to run it protects the page and waits until all threads have segfaulted and transferred control to the collector.