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.

A banking application, where we have a deposit and withdraw on the

same account. The two functions are running in two different threads. Execute

  1. 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.
  2. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!