The code for sleeping barber problem. When the status of the barber
is set to busy then the customer cannot have a hair cut and is added to the
waiting queue. when the customer is set to free then the customer have a
hair cut.
Here the problem is that only the first customer have a hair cut and the other
customers added in the queue cannot have a hair cut.
Any help will be appreciated.
customeradd class:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* cutomeradd.java
*
* Created on Apr 4, 2010, 12:47:17 PM
*/
package gui;
import customer.Customer;
/**
*
* @author hp
*/
public class cutomeradd extends javax.swing.JFrame {
public static int enteredcustomerpos=1;
/** Creates new form cutomeradd */
public cutomeradd() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOTe modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
addCusotmer = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
addCusotmer.setText("Add");
addCusotmer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
addCusotmerActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(71, 71, 71)
.addComponent(addCusotmer)
.addContainerGap(98, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(42, 42, 42)
.addComponent(addCusotmer)
.addContainerGap(57, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
@SuppressWarnings("static-access")
private void addCusotmerActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your …