Question: A banking application, where we have a deposit and withdraw on the same account. The two functions are running in two different threads. Execute the
A banking application, where we have a deposit and withdraw on the same account. The two functions are running in two different threads.


- Execute the same solution by taking input from the user for the initialization of the class and then generating random deposits and random withdraw amounts.
- Now try to implement the same functionality using extend Thread library.
(Note: You must need answer question "B". Then provide solutions to the answer. )
Java
public class Account private float balance: private float rate: public int acct Number: public Account (float b, float I, int num) balance - b rate - : acet Number - num; 1 /* The following methods must be synchronized to avoid the possibility of threads changing the values inconsistently. public synchronized void deposit(float amount) { balance += amount: System.out.println("Account - + acct Number + - deposited :- + amount + - Balance is : - + balance): 1 public synchronized void withdraw(float amount) { if (balance
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
