-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
57 lines (55 loc) · 1.14 KB
/
README
File metadata and controls
57 lines (55 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com;
class Account
{
private int acc_no;
private long balance;
public Account()
{
acc_no=0;
balance=0;
}
public Account(int acc_no,long balance)
{
this.acc_no=acc_no;
this.balance=balance;
}
public long getBalance()
{
return(balance);
}
public synchronized void deposite(int amt)
{System.out.println("Deposite");
balance=balance+amt;
System.out.println("Deposite is completed by "+Thread.currentThread().getName());
System.out.println("Balance after deposite is="+balance);
this.notify();
}
public synchronized void withdraw(int amt)
{System.out.println("Withdraw");
long temp,flag=1;
while(flag!=0)
{
temp=balance;
if((temp-(amt)>=500))
{
temp=temp-amt;
balance=temp;
flag=0;
}
else
{
try
{
System.out.println("Insufficient balance "+Thread.currentThread().getName()+" is waiting");
wait();
}
catch(Exception ie)
{
ie.printStackTrace();
}
}
}
System.out.println("Withdraw is completed by "+Thread.currentThread().getName());
System.out.println("Balance after withdraw is="+balance);
}
}