Java Multithreaded Bank Account Using Locks

Feb 3rd, 2012
Studypool Tutor
Price: $30 USD

Tutor description

Title: “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 the deposits and withdrawals will be made by synchronized threads. 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 w

Word Count: 603
Showing Page: 1/4
/**********************************************************************************************************//** * This class represent the Bank Account on which all the withdraw and deposit transaction would happen. */public class BankAccount { /** * The total amount in the account */ private static double total = 0; /** * Function to withdraw the amount * @param amount double */ public void withdraw(double amount) { total -= amount; } /** * Function to deposit the amount * @param amount double */ public void deposit(double amount) { total += amount; } /** * Function to get the account total * @return */ public double getTotal() { return total; }}/**********************************************************************************************************/import java.util.concurrent.locks.Condition;import java.util.concurrent.locks.Lock;import java.util.concurrent.locks.ReentrantLock;/** * The class to do the actual withdrawal and deposit to the bank account */public class BankAccountManager { /** * The lock which would be usedby threads

Review from student

Studypool Student
" This tutor is great! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1821 tutors are online

Brown University





1271 Tutors

California Institute of Technology




2131 Tutors

Carnegie Mellon University




982 Tutors

Columbia University





1256 Tutors

Dartmouth University





2113 Tutors

Emory University





2279 Tutors

Harvard University





599 Tutors

Massachusetts Institute of Technology



2319 Tutors

New York University





1645 Tutors

Notre Dam University





1911 Tutors

Oklahoma University





2122 Tutors

Pennsylvania State University





932 Tutors

Princeton University





1211 Tutors

Stanford University





983 Tutors

University of California





1282 Tutors

Oxford University





123 Tutors

Yale University





2325 Tutors