class Account{
private double amount = 1000;
public synchronized void withdraw(float amt){
amount = amount - amt ;
}
public double checkBalance(){
return amount;
}
}
public class RunSync implements Runnable{
private Account account = new Account();
public void run(){
for(int i = 0;i<5;i++){
account.withdraw(100);
try {
public static void main(String[] args) {
RunSync r = new RunSync();
Thread t1 = new Thread(r,"husband");
Thread t2 = new Thread(r,"wife");
t1.start();
t2.start();