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

  Creates an object from the person class

Which of the following creates an object from the Person class?

  Write program to bounce blue ball inside jpanel

Write a program which bounces the blue ball inside JPanel. Ball must begin moving with the mousePressed event. When ball hits edge of JPanel, it must bounce off edge.

  Create a project displays aisle number of movie category

A Search Button should located the correct location. from the array and display it in a lable. Make sure that the user has selected a category from the list and use the list box SelectedIndex property to find the appropriate aisle number.

  Write program which instantiates objects of classes

Private data of Quadrilateral must be the x-y coordinate pairs for four end-points of the Quadrilateral. Write a program which instantiates objects of your classes and outputs each objects area (except Quadrilateral.

  Implement the calculator using stacks and queues

You will implement the calculator using stacks and queues. Your calculator should support following operators: Parenthesis. The input will be given in form of infix expressions, e.g. ( 2 + 3 ) * 5.

  Prompt user to enter two integer and read them from keyboard

Create a loop, and inside of it replace the larger integer with the difference between the larger integer and the smaller integer (if the integers are equal you may choose either one as the "larger")

  Prepare a scenario diagram for problem

Write a PhoneContact class that gets initialized with a phone number and a label. The phone number should follow one of the formats of the Phone class from the previous assignment - Prepare a scenario diagram for Problem 1, Brief discussion for Pro..

  Functions of standard and statistical calculators

Write a windows application in Visual Basic to perform functions of standard and statistical calculators.

  Application for calculation

Which school had the most kids playing basketball

  Discuss the concept of reusability

Designing for Reusability- Discuss the concept of reusability and how to design for reusability. Provide an example with your posting

  Write a program to output accumulated values for each month

Write a program to output accumulated values for each month, given a set amount saved each month, until the accumulated amount reaches a set goal amount.

  Write program which takes as input arithmetic expression

Write program which takes as input an arithmetic expression. The program outputs whether expression contains matching grouping symbols.

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