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 (I’ll let you use my real bank account if you promise to make only deposits! J). 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 withdraw an amount greater than the current balance in the account – then it must block itself and wait until a deposit has occurred before it can try again. As we covered in the lecture notes, this will require that the depositor threads signal all waiting withdrawal threads whenever a deposit is completed
Get Free Quote!
295 Experts Online