Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. package clientescolacircular;
  2. import colacircular.*;
  3.  
  4.  
  5.  
  6.  
  7. /**
  8. * Los objetos de esta clase son hilos que crean e introducen en la cola circular objetos del tipo ObjetoTest.
  9. *
  10. * @author adolfo
  11. *
  12. */
  13. public class HilosQueEncolan extends Thread{
  14.  
  15. private ColaCircular cola;
  16.  
  17. public HilosQueEncolan(ColaCircular cola) {
  18. this.cola = cola;
  19. }
  20.  
  21. public void run() {
  22. while (true) {
  23. int n = (int)Math.round(1000*Math.random());
  24. ObjetoTest ot = new ObjetoTest();
  25. ot.inf = n;
  26. try {
  27. cola.encolar(ot);
  28. } catch (InterruptedException e) {
  29. e.printStackTrace();
  30. // TODO: handle exception
  31. }
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement