Download Part A and C
Transcript
19
- Save a file barber.bat with this text included:
-@java -Djava.security.policy=everything.policy Barber
-Click barber.bat
-Save a file barber.bat with this text included:
@java -Djava.security.policy=everything.policy Customer
-Click customer.bat
The code for Sleeping barber
//Customer class
import java.util.Random;
import java.rmi.Naming;
/**
* This class implements multiple clients for the barber.
* Amount of clients is static and each client is running
* on a separate thread.
*/
public class Customer implements Runnable
{
// personal id for each of the clients
private int id;
// the salon attached to the customer
private SalonInterf salonInterf;
public Customer(int id, SalonInterf salonInterf)
{
// set customer id
this.id = id;
// start the client
this.salonInterf = salonInterf;
new Thread(this).start();
}
public void run()
{
while(true)
{
System.out.println("Customer " + this.id + ":
growing hair...");