Simulate the deposits made to a fictitious bank account

Assignment Help Programming Languages
Reference no: EM131310526

Program Assignment: Multi-threaded Programming in Java Using Locks

Objectives: To practice programming cooperating, synchronized multiple threads of execution.

Description: In this programming assignment you will simulate the deposits and withdrawals made to a fictitious bank account. In this case synchronized threads will make the deposits and withdrawals. Synchronization is required for two reasons (1) mutual exclusion (updates cannot be lost) and (2) because a withdrawal cannot occur if the amount of the withdrawal request is greater than the current balance in the account. This means that access to the account (the shared object) must be synchronized. This application requires cooperation and communication amongst the various threads (cooperating synchronized threads). (In other words, this problem is similar to the producer/consumer problem where there is more than one producer and more than one consumer process active simultaneously.) If a withdrawal thread attempts to withdraw an amount greater than the current balance - then it must block and wait until a deposit has occurred before it can try again. As we covered in the lecture notes, this will require that the deposit threads signal all waiting withdrawal threads whenever a deposit is completed.

1. To keep things relatively simple as well as to see immediate results from a series of transactions (deposits and withdrawals) assume that deposits are made in amounts ranging from $1 to $200 (even dollars only) and withdrawals are made in amounts ranging from $1 to $50 (again, even dollars only).

2. You should have three deposit threads and four withdrawal threads executing simultaneously.

3. Once a deposit thread has executed, put it to sleep for a millisecond or so (depends a little bit on the speed of your system as to how long you will want to sleep the depositor threads - basically we want to ensure a lot more withdrawals than deposits) to allow other threads to execute. This is the only situation in which a deposit thread will block.

4. Once a withdrawal thread has executed, have it yield to another thread (don't put it to sleep though). This will prevent a single withdrawal thread from gaining the CPU and then executing a long sequence of withdrawal operations. Withdrawal threads block if they attempt to withdraw more than the current balance in the account.

5. Assume all threads have the same priority.

6. The output from your program must look reasonably similar to the sample output shown below.

7. Do not put the threads into a counted loop for your simulation. In other words, the run() method should be an infinite loop.

8. Do not use the Java synchronized statement. I want you to handle the locking and signaling yourself. No monitors!

References:

Notes: Lecture Notes for Multithreaded Applications.

Input Specification: Internal to the program.

Output Specification: Console based. Your output should appear reasonably similar to the output shown below.

Additional Information:

Shown below are a couple of example screen shots of the output from this program to help illustrate how your application is to operate and display the results.

Reference no: EM131310526

Questions Cloud

What decides to use tcp or udp : Network switches provide essential connectivity in local and wide area networks. Some of them run in multilayer between layers 2 and 3. What protocol unit is being used in layer 2?The backbone of the Internet is structured by the Internet Protocol ..
At what air speed should the model test be performed : The drag on a 2-m-diameter satellite dish due to an 80 km/h wind is to be determined through wind tunnel testing on a geometrically similar 0.4-m-diameter model dish.
Determine the moles of water that are required per mole : Determine the moles of water that are required per mole of H2S-free carrier gas if 1.5 times the minimum ratio will be used.
How fast must the wing move through the air : How fast must the wing move through the air at an altitude of 35,000 ft if it is to generate the same lift? (Assume the lift coefficient is constant.)
Simulate the deposits made to a fictitious bank account : In this programming assignment you will simulate the deposits and withdrawals made to a fictitious bank account. In this case synchronized threads will make the deposits and withdrawals.
Determine moles of steam if countercurrent tower is used : A wash-oil flow rate of 6.94 mol/s will be used.- Determine the required moles of steam if a countercurrent tower is used;  a cocurrent tower is used.
Create a professional quality powerpoint presentation : Using the readings from the text and your research, create a professional quality PowerPoint presentation that conveys the results of your research into social media, various platforms and outlets, and types of messaging and content that are most ..
Write application that allows you to enter amount of money : Write a windows application that allows you to enter the amount of money in your savings account, the interest rate, and a number of years.
Determine how many students scored above the average : He wants to average the grades for his last exam in his medieval literature course and then determine how many students scored above the average and how many scored below.

Reviews

Write a Review

Programming Languages Questions & Answers

  Write a program a to program to compute the area

Write a program a to program to compute the area A of a triangle with base b and height h. Write a program to a program to compute the volume V of a sphere of radius r.

  Define a class rewardcard as an adt

Determine the cost of the two_day_ package represented by the instantiated object, then display the calculated cost also on the console - Define a class RewardCard as an ADT that uses separate files for the interface and the implementation

  Which of the following is not included in a pseudocode

Which of the following is not included in a pseudocode program?

  Create a windows form application project.

After these two selections are made the user will click the Selection Complete button that will compute the total price of rental

  Create a script that requires your visitors to accept

If the check box is not selected, display an alert dialog box information the user that he or she must accept the terms. if the user clicks the Decline link, open the Declinepage.html document.

  Create a user form that contains the usual ok and cancel

Create a user form that contains the usual OK and Cancel buttons

  Write a program that will allow a user to enter in a

write a program that will allow a user to enter in a sentence of up to 100 characters. then take that sentence and

  Write a program that reads a number in feet

Write a program that reads a number in feet, converts it to meters, and displays the result. One foot is 0.305 meters.

  The process of identifying the classes or functions

How the two programs were selected and The process of identifying the classes or functions for replacement

  Design this program using an algorithm of your choice

Design this program using an algorithm of your choice, draw the flowchart and convert the flowchart into a C++ Program.

  Approach for building site in-house with existing staff

Web site Consider your options for building the site in-house with existing staff, or outsourcing the entire operation. Decide which strategy you believe is in your company's best interest and create a brief presentation outlining your position.

  Design a gui class that should be hand-coded

The program should consist of three classes. The first class should define the GUI and should be hand-coded and not generated by a GUI generator.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd