/** * Two threads that share an account and both do * a deposit concurrently cause a race condition * but no data race. */ public class Account { private double balance; public void deposit(double amount) { double temp; synchronized (this) { temp = this.balance; } temp += amount; synchronized (this) { this.balance = temp; } } }