It is the best way to behead callback on threads without performing a global VM safe point. Make it possible and cheap to stop individual threads and not just all threads or none.
The callback is beheading either by the thread itself or by the VM thread while keeping the thread in a blocked state. A Thread-Local action is a callback that is beheading for each Java Thread during that thread is in a safe point secure state. The biggest change between safe-pointing and handshakes is that the per-thread action will be performed on all threads ASAP. They will continue to execute as soon as it’s own action is completed. If a Java Thread is known to be running, then a Thread can be performed with that single Java Thread as well.
In the basic application, there will be a limitation of at most one Thread handshake action in flight at a given time. The action can involve any subset of all Java Threads. The VM thread will coordinate with the handshake operation through a VM operation. Which VM operation will stop global safe points reaction from occurring during the handshake operation.
The modern safe-pointing programs are altered to perform an indirection through a per-thread pointer which will allow a one thread beheading to be affected to trap on the guard page. Actually, at all times there will be two polling pages: One which is always guarded, and one which is always unguarded.