public class BankAccount { public synchronized void deposit(double amount) { . . . } public synchronized void withdraw(double amount) { . . . } . . . }