Name: B.
Latha Sagar
RegNo: 12204652
Roll No: 42
Section: D2212
Course Code: CAP680
Assignment-8
source code:
package assignment;
import java.util.*;
public class Bank
synchronized void deposit()
System.out.println("Enter the amount to deposit :");
Scanner sc=new Scanner(System.in);
int deposit=sc.nextInt();
System.out.println("Amount Successfully Deposited "+deposit);
System.out.println("Enter amount for withdraw :");
int withdraw=sc.nextInt();
System.out.println("Amount Successfully withdrawn "+withdraw);
int totalBalance=deposit-withdraw;
System.out.println("Total current balance : "+totalBalance);
try {
Thread.sleep( 1000);
catch(Exception e)
public static void main(String[]args)
Bank s=new Bank();
Customer1 f=new Customer1(s);
Customer2 a=new Customer2(s);
f.start();
a.start();
class Customer1 extends Thread
Bank s1;
Customer1( Bank s1)
this.s1=s1;
public void run()
s1.deposit();
class Customer2 extends Thread
{
Bank s2;
Customer2( Bank s2)
this.s2=s2;
public void run()
s2.deposit();
Output: