Advertisement
LEANDRONIEVA

Tp5ProductorConsumidorMain

Oct 8th, 2023
649
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Random;
  3.  
  4. public class Punto1 {
  5.  
  6.     public static void main(String[] args) {
  7.         // TODO Auto-generated method stub
  8.  
  9.         ArrayList<Integer> lista = new ArrayList<>();
  10.         Random random = new Random();
  11.         int aux;
  12.        
  13.         for(int i = 0; i < 10; i++) {
  14.             aux = random.nextInt(100,200);
  15.             try {
  16.                 Thread.sleep(aux);
  17.                
  18.                 Productor prod = new Productor(lista,i);
  19.                 Consumidor cons = new Consumidor(lista,i);
  20.                
  21.                 prod.start();
  22.                 cons.start();
  23.                    
  24.             } catch (InterruptedException e) {
  25.                 // TODO Auto-generated catch block
  26.                 e.printStackTrace();
  27.             }
  28.            
  29.         }
  30.     }
  31.  
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement