lMutual Exclusion (preventing simultaneous access to shared data) can be accomplished using the synchronized access specifier
–synchronized
boolean withdraw(int amount) {
– ….
–}
–Or using the synchronized block:
–boolean
withdraw(int amount) {
– synchronized(this {
– ….
– }
–}