Alejandro_S_Mercado

Untitled

Sep 24th, 2025
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.77 KB | None | 0 0
  1. public class Main {
  2.  
  3.     public static void main(String[] args) {
  4.         ArrayList <Object> mostrador=new ArrayList<>();
  5.         int numCliente=1;
  6.         Random random=new Random();
  7.         ProductorBizcocho produccionBizcochos=new ProductorBizcocho(mostrador);
  8.         ProductorFactura produccionFactura= new ProductorFactura(mostrador);
  9.        
  10.         produccionBizcochos.start();
  11.         produccionFactura.start();
  12.        
  13.         while(true) {
  14.             try {
  15.             int timeStart=random.nextInt(1500-800)+800; //esto hace que los clientes parezcan secuenciales
  16.             Thread.sleep(timeStart);
  17.             ConsumidorCliente cliente=new ConsumidorCliente(mostrador,numCliente);
  18.             cliente.start();
  19.             //cliente.join(); //Para atender de uno en uno
  20.             numCliente++;
  21.             }catch(InterruptedException e) {
  22.                 e.printStackTrace();
  23.             }
  24.         }
  25.  
  26.        
  27.     }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment