Advertisement
LEANDRONIEVA

Clase Factura

Oct 14th, 2023
803
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Random;
  2. import javax.lang.model.element.Element;
  3.  
  4. public class Factura 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 = 1300;
  11.     private int lim_inferior = 1000;
  12.  
  13.     public Factura(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.             int elemento = this.indice;
  23.             cola.agregarFactura(elemento);
  24.             System.out.println("Factura " + this.indice +" se añadió al mostrador");
  25.             try {
  26.                 Thread.sleep(random.nextInt(this.lim_inferior, this.lim_superior));
  27.             } catch (InterruptedException e) {
  28.                 Thread.currentThread().interrupt();
  29.             }
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement