Question: Need help with this JAVA threading problem: Write a class called TellerMachine that simulates an ATM. It should contain two methods deposit() and withdraw(). It

Need help with this JAVA threading problem:
Write a class called TellerMachine that simulates an ATM. It should contain two methods deposit() and withdraw(). It also contains a private variable called accountBalance. The deposit() method allows a thread to deposit $500, and update the account balance. The withdraw() method allows a thread to remove $120, and update the account balance.
Write a main method that creates two threads. One of the threads (called Deposit Thread) should execute the deposit() method. The other thread (called Withdraw Thread) should execute the withdraw() method.
* You need to make sure that there is no race occurs between the deposit and withdraw threads.

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!