Friday, December 09, 2005

3. Sleeping Barber - code

Here are the programs for Semaphore, SleepingBarber and SleepingBarberD described before.SleepingBarberD differs only by the addition of delay to the customers.

Semaphore.java-----------------------------------// This count implements a classic counting Semaphore// It has two synchronized operations which it can perform// up - increments the count of the semaphore and wakes up// waiting threads// down - decrements the count of the semaphore or if zero// suspends the thread