private Object thisLock = new Object();
public Account(int initial)
throw new Exception("Negative Balance");
Console.WriteLine("Balance before Withdrawal : " + balance);
Console.WriteLine("Amount to Withdraw : -" + amount);
balance = balance - amount;
Console.WriteLine("Balance after Withdrawal : " + balance);
public void DoTransactions()
for (int i = 0; i < 100; i++)
Withdraw(r.Next(1, 100));
public static void Main()
Thread[] threads = new Thread[10];
Account acc = new Account(1000);
for (int i = 0; i < 10; i++)
Thread t = new Thread(new ThreadStart(acc.DoTransactions));
for (int i = 0; i < 10; i++)