Home Page | Downloadable PDF | Download Source
Main Page | Alphabetical List | Class List | File List | Class Members

Bankers Algorithm Using Threads

Introduction and Overview

Bankers Algorithm This program uses multiple threads of execution to simulate the Bankers Algorithm. The Bankers Algorithm is a common problem used to illustrate thread management through a simulation of having many customers who need resources from a bank, and a bank that has a set number of resources to provide those customers. If a customers request is granted the customer then holds the resources until all of his/her needs have been met, then the customer returns all resources to the bank.

This presents a problem of the possibilty of Thread Lock if resources are granted in such a manner that prevents any customer from fullfilling its needs, because other customers are holding resources that are needed. This problem leads to the need for managing Thread Safety during the execution of the program to closely manage the allocation of resources as to avoid this dillema.

Program Usage

Compile each of the three source files (Bank.java, Customer.java, and RunBank.java)
dev@tux> javac Bank.java
	 javac Customer.java
	 javac RunBank.java
 

Then simply execute RunBank

dev@tux> java RunBank 

Generated on Mon Oct 17 23:38:29 2005 for Bankers Algorithm by  Cody Precord