Guest User

Untitled

a guest
Jul 17th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. /**
  2. * **********************************************************************
  3. * Declaración de variables
  4. *
  5. * **********************************************************************
  6. */
  7. public static Thread t;
  8. private int separacion = 0;
  9. private float Qhec;
  10. private float velocidad;
  11. private boolean suspendFlag;
  12.  
  13. public Hilo1() {
  14.  
  15. t = new Thread(this);
  16. Qhec = 0;
  17. t.start(); // Comienza el hilo
  18. }
  19.  
  20. public void run() {
  21. while (true) {
  22. try {
  23. calcularCaudalHectareo(xx);//En xx iria el numero a evaluar
  24. t.sleep(1500);
  25. synchronized (this) {
  26. while (suspendFlag) {
  27. wait();
  28. }
  29. }
  30. } catch (InterruptedException ex) {
  31. Logger.getLogger(HiloMapear.class.getName()).log(Level.SEVERE, null, ex);
  32. }
  33. }
  34. }
  35.  
  36. public void mysuspend() {
  37. suspendFlag = true;
  38. }
  39.  
  40. public synchronized void myresume() {
  41. suspendFlag = false;
  42. notify();
  43. }
  44.  
  45. public void calcularCaudalHectareo(double QHorario) throws IOException {
  46. velocidad = pp.central.getVelocidad();//Pp es el objeto desde donde traigo la velocidad actualizada
  47. if (velocidad == 0 || separacion == 0) {
  48. Qhec = 0;
  49. } else {
  50. Qhec = (float) ((QHorario * 60) / (separacion * velocidad));
  51. }
  52. this.pp.ce.setCaudal(Qhec);//Seteo al objeto pp el caudal obtenido
  53. }
Add Comment
Please, Sign In to add comment