salve,
Ecco cosa richiede l'applicazione:
Bisogna gestire il flusso di persone che arriva allo sportello postale. L'applicazione ha un'interfaccia grafica che consente di inserire il nome e cognome della persona. L'insieme delle persone viene mantenuto in una struttura dati con politica fifo, e ogni persona viene associata a uno sportello libero per la durata compresa tra i 5 e 20 secondi, mentre se lo sportello è occupato , la persona viene messa in attesa. il numero massimo di persone in attesa è 10.


Ora veniamo al dunque:
Non so proprio come gestire questa situazione con l'utilizzo dei thread produttori - consumatori. Qualcuno può aiutarmi?

ho creato la seguente interfaccia grafica :
codice:
package it.unisa.oop;

import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;


public class InterfacciaGrafica extends JFrame{
    private JLabel lSportello1;
    private JLabel lSportello2;
    private JLabel lSportello3;
    private JLabel lSportello4;
    private JTextField tSportello1;
    private JTextField tSportello2;
    private JTextField tSportello3;
    private JTextField tSportello4;
    private JLabel lNome;
    private JLabel lCognome;
    private JTextField tNome;
    private JTextField tCognome;
    private JButton inserimento;
    
    
    
    public InterfacciaGrafica(){
        super();
        initGui();
    }
    
    private void initGui() {
     try{
         for(LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()){
             if("Nimbus".equals(info.getName())){
                 UIManager.setLookAndFeel(info.getClassName());
                 break;
             }
         }
         
        this.setTitle("POSTE ITALIANE");
        this.setSize(1200,270);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setResizable(false);
        this.setLocation(100,300);
        
        GridBagLayout gb = new GridBagLayout();
        gb.columnWeights = new double[]{0.1,0.1,0.1,0.1,0.1};
        gb.columnWidths = new int[]{200,280,200,200,330};
        gb.rowWeights = new double[]{0.1,0.1,0.1,0.1};
        gb.rowHeights = new int []{10,10,10,10};
        this.setLayout(gb);
        
        
        {
            lSportello1 = new JLabel("Sportello 1");
            lSportello1.setFont(new Font("", Font.BOLD,22));
            this.add(lSportello1, new GridBagConstraints(0,0,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,10,0,0),0,0));
        }
        
        {
            lSportello2 = new JLabel("Sportello 2");
            lSportello2.setFont(new Font("", Font.BOLD,22));
            this.add(lSportello2, new GridBagConstraints(0,1,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,10,0,0),0,0));
        }
        
        {
            lSportello3 = new JLabel("Sportello 3");
            lSportello3.setFont(new Font("", Font.BOLD,22));
            this.add(lSportello3, new GridBagConstraints(0,2,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,10,0,0),0,0));
        }
        
        {
            lSportello4 = new JLabel("Sportello 4");
            lSportello4.setFont(new Font("", Font.BOLD,22));
            this.add(lSportello4, new GridBagConstraints(0,3,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,10,0,0),0,0));
        }
        
        {
            tSportello1 = new JTextField();
            tSportello1.setToolTipText("Utente Corrente");
            tSportello1.setFont(new Font("", Font.BOLD,22));
            tSportello1.setEditable(false);
            this.add(tSportello1, new GridBagConstraints(1,0,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0));
        }
        
        
        {
            tSportello2 = new JTextField();
            tSportello2.setToolTipText("Utente Corrente");
            tSportello2.setFont(new Font("", Font.BOLD,22));
            tSportello2.setEditable(false);
            this.add(tSportello2, new GridBagConstraints(1,1,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0));
        }
        
        {
            tSportello3 = new JTextField();
            tSportello3.setToolTipText("Utente Corrente");
            tSportello3.setFont(new Font("", Font.BOLD,22));
            tSportello3.setEditable(false);
            this.add(tSportello3, new GridBagConstraints(1,2,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0));
        }
        
        
        {
            tSportello4 = new JTextField();
            tSportello4.setToolTipText("Utente Corrente");
            tSportello4.setFont(new Font("", Font.BOLD,22));
            tSportello4.setEditable(false);
            this.add(tSportello4, new GridBagConstraints(1,3,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0));
        }
        
        {
            lNome = new JLabel("Nome:");
            lNome.setFont(new Font("", Font.ITALIC,22));
            this.add(lNome, new GridBagConstraints(3,0,1,1,0.0,0.0,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0));
        }
        
        {
            lCognome = new JLabel("Cognome:");
            lCognome.setFont(new Font("", Font.ITALIC,22));
            this.add(lCognome, new GridBagConstraints(3,1,1,1,0.0,0.0,GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,0),0,0));
        }
        
        {
            tNome = new JTextField();
            tNome.setToolTipText("Inserire il nome dell'utente!!!");
            tNome.setFont(new Font("", Font.ITALIC,22));
            this.add(tNome, new GridBagConstraints(4,0,1,1,0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,30),0,0));
        }
        
        {
            tCognome = new JTextField();
            tCognome.setToolTipText("Inserire il cognome dell'utente!!!");
            tCognome.setFont(new Font("", Font.ITALIC,22));
            this.add(tCognome, new GridBagConstraints(4,1,1,1,0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,30),0,0));
        }
        
        {
            inserimento = new JButton("Inserimento");
            inserimento.setFont(new Font("", Font.TYPE1_FONT,22));
            this.add(inserimento, new GridBagConstraints(3,2,2,1,0.0,0.0,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0,0,0,30),0,0));
            inserimento.addActionListener(new ActionListener(){

                @Override
                public void actionPerformed(ActionEvent e) {
                    if(tNome.getText().isEmpty() || tCognome.getText().isEmpty()){
                        JOptionPane.showMessageDialog(getContentPane(),"Riempire tutti i campi!!!", "Warning",JOptionPane.WARNING_MESSAGE);
                    }
                }
                
            });
        }
    }catch(Exception e){}
     
  }
    public static void main(String [] args){
        SwingUtilities.invokeLater(new Runnable(){

            @Override
            public void run() {
                InterfacciaGrafica gui = new InterfacciaGrafica();
                gui.setVisible(true);
            }
            
        });
    }
    
    
    
    
}