Synchronization என்பது operations ஆபத்தாக ஒன்றோடொன்று கலக்காதபடி பகிரப்பட்ட mutable state-க்கு threads-இன் அணுகலை ஒருங்கிணைக்கிறது, இது race conditions-ஐ தடுக்கிறது. Java பல்வேறு பொறிமுறைகளை வழங்குகிறது, உள்ளமைக்கப்பட்ட synchronized keyword முதல் explicit locks மற்றும் lock-free atomics வரை.
synchronized — mutual exclusion (intrinsic locks)
{
balance;
{
(balance >= amount) {
balance -= amount;
}
}
{
() {
balance += amount;
}
}
}
