JAC444 Workshop 9 Multi-Threaded programming

$30.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (5 votes)

This assignment lets you practice Multi-Threaded programming in Java and includes concepts
such as Threads, Guarded Blocks, and Synchronization.
Give a solution to the following problem:
You want to help your friend with some money. You and your friend have access to a shared
account, but in a “Strange Bank.”
The Strange Bank has the following rule for the accounts: once you deposit some money in some
currency (to an account with an initial balance of zero,) you are not allowed to deposit money in
another currency, unless the account balance would be zero (again.)
You have one Dollar, two Euros, and three Pounds and you want to transfer these amounts to
your friend. Write a Java program that simulates you depositing to and your friend withdrawing
from the shared account.
Hints: You and your friends are Java Threads that try to access the bank account concurrently
(you to deposit, your friend to withdraw). You must communicate through wait and notify
methods.
Make sure that all the deposit and withdraw actions between you and your friend should
happen to be in amounts of one (at a time).
This is a classical problem in thread theory called “Producer/Consumer” in which there
is a container that accepts only one object at a time. Producer wants to put in the container as
many objects as it produces but must wait until the consumer consumes the already-shared
object from the container.
Marking Criteria and Tasks:
Please note that you should:
a- have appropriate indentation.
b- have proper file structures and modularization.
c- follow Java naming conventions.
d- document all the classes properly.
e- not have debug/useless code and/or file(s) left in assignment.
f- have good intra and/or inter class designs.
in your code!
• Task: Developing and running the desired solution: (you should submit your source
code – just individual .java files, and screenshots which demonstrate all the
different/possible ways your code runs): 5 marks.
JAC444 Summer – 2020 2
27/07/2020 Workshop 9 Page 2 of 2
Deliverables and Important Notes:
• You are supposed to submit your solution online on Bb by the end of the day on
Monday, 3
rd of August, 2020.)
• Please note that you would be allowed to submit just once, so please be super
careful and double check before you hit submit.
• There would be a 20% penalty for each day (or part of it,) in case you submit
late!
• Remember that you are encouraged to talk to each other, to the instructor, or to
anyone else about any of the assignments, but the final solution may not be copied
from any sources.