Advertisement
LEANDRONIEVA

Clase Bizcocho

Oct 14th, 2023
895
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. import java.util.Random;
  2. import javax.lang.model.element.Element;
  3.  
  4. public class Bizcocho extends Thread{
  5.  
  6.     private static int contador = 0;
  7.     private int indice;
  8.     private Mostrador<Element> cola;
  9.     private Random random = new Random();
  10.     private int lim_superior = 600;
  11.     private int lim_inferior = 400;
  12.    
  13.     public Bizcocho(Mostrador<Element> mostrador) {
  14.         contador++;
  15.         this.indice = contador;
  16.         this.cola = mostrador;
  17.     }
  18.    
  19.     public void run() {
  20.         while (true) {
  21.             // System.out.println((cola.toString()));
  22.             cola.agregarBizcocho(this.indice);
  23.             System.out.println("Bizcocho " + this.indice +" se añadió al mostrador");
  24.             try {
  25.                 Thread.sleep(random.nextInt(this.lim_inferior, this.lim_superior));
  26.             } catch (InterruptedException e) {
  27.                 Thread.currentThread().interrupt();
  28.             }
  29.         }
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement