A method for synchronizing threads in a computer operating under control of
a program written in an object-based computer programming language
provides for a first thread to lock an object by moving the object header
to a stack address and replacing the header with the stack address. The
first thread unlocks the object by returning the header to its associated
memory location. Second and subsequent threads attempting to access a
locked object detect the presence of the stack address in the header
memory location and suspend their attempts to access the object. When
using aligned stacks, all stack addresses will be even, and all
object-headers will be odd. Threads efficiently check the status of the
object by testing the least significant bit. A preferred method is
implemented in a "JAVA" just-in-time compiler of a "JAVA" virtual machine.
Un metodo per la sincronizzazione dei filetti in un calcolatore che funziona sotto il controllo di un programma scritto in una lingua oggetto-basata di programma destinato all'elaboratore prevede un primo filetto per bloccare un oggetto spostando l'intestazione dell'oggetto verso un indirizzo della pila e sostituendo l'intestazione con l'indirizzo della pila. Il primo filetto sblocca l'oggetto restituendo l'intestazione alla relativa posizione di memoria collegata. In secondo luogo e filetti successivi che tentano di accedere ad un oggetto locked rilevi la presenza dell'indirizzo della pila nella posizione di memoria dell'intestazione e sospenda i loro tentativi di accedere all'oggetto. Quando usando ha allineato le pile, tutti gli indirizzi della pila saranno uniformi e tutte le oggetto-intestazioni saranno dispari. I filetti controllano efficientemente la condizione dell'oggetto verificando la meno punta significativa. Un metodo preferito รจ effettuato in un compilatore just-in-time "del JAVA" di una macchina virtuale "del JAVA".