Simulate deposits and withdrawals made to fictitious account

Assignment Help JAVA Programming
Reference no: EM131310211

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.

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.

Reference no: EM131310211

Questions Cloud

Describe why teams are being formed more frequently : Describe why teams are being formed more frequently in business today. What are some of the special considerations required for a team to be successful?
Appropriate for staffing each group : Which model will be most appropriate for staffing each group: ethnocentric model, polycentric model, or global model? Explain your reasoning for each case.
Distinguish between reliability and character based trust : Distinguish between reliability and character-based trust. Why is character-based trust critical in collaborative relationships?
Create a list of at least 8 performance measures for this : Use the Internet to research performance measures for the position of a payroll clerk. (You may want to refer back to the U.S. Department of Labor's Occupational Outlook Handbook).Create a list of at least 8 performance measures for this position.
Simulate deposits and withdrawals made to fictitious 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.
What must coupon rate be on the bonds : Barnes Enterprises has bonds on the market making annual payments, with 18 years to maturity, a par value of $1,000, and a price of $960. At this price, the bonds yield 8.7 percent. What must the coupon rate be on the bonds?
Compare and contrast various metric for product availability : Compare and contrast the various metrics for product availability. Why is the order fill rate considered the most stringent metric?
Distinguish between a policy requirement and a mechanism : Distinguish between a policy requirement and a mechanism. Identify at least three specific security requirements for a system you know and describe at least two different mechanisms for implementing each one.
Is the ideal of a perfect order a realistic operational goal : Why are comprehensive measures of supply chain performance, such as total supply chain cost, so difficult to develop?

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  How do i automatically set the input focus in my applet

How do I automatically set the input focus in my applet to a specific component/text field when the browser loads the page that contains the applet?

  Algorithm analysis with advanced data structures

Write a program to help the merchants devise a sequence of transmutations that would change silver into gold with the smallest possible total fee paid to the alchemists.

  Write an application that reads determines the surface area

Write a program that uses the top five countries' National Wealth to calculate the average of those five countries.

  Difference for class linked bag and test into main program

write a method difference for the class linked bag and test into main program.

  Insert uml design diagrams, use case, classes

Insert UML design diagrams here (use case, class, and sequence diagram).

  Prints out your gradebook entries

Create a new gradebook entry for four different CSCI courses. Must use a constructor to initialize the course name - Prints out your gradebook entries

  Create a class named student that has three member variables

Create a class named Student that has three member variables

  Explore how to throw and rethrow and exception

We will explore how to throw and rethrow and exception, and how to handle events in a program.  Please respond to all of the following prompts:Discuss whether it is it possible

  Designing a program with a while loop

The section entitled "In the Spotlight", "Designing a program with a while loop" describes the requirements for a project at Chemical Labs, Inc. Write a letter to the Director of Engineering that describe your concerns, if any, regarding these re..

  Assignment in python

You will complete this assignment in Python 3.x. Make sure you have downloaded the software and it is installed correctly. You will download it from this site: https://www.python.org/downloads/.

  Create a folder with yourlastnamefirstinitialle73

Create a folder with YourLastNameFirstInitialLE73. Inside of that folder create 3 more folders:  In DrJava create a project folder (Creating Projects in DrJava.pdf )  asYourLastNameFirstInitialLE73.

  You need to prepare the java applet

If the typed number is valid, display a product description and price; otherwise, display an appropriate error message. Save the file as JProductFinder.java.

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