Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package KlausurVorbereitung2;
  2.  
  3. public class RasenmäherMischung1 extends Thread
  4. {
  5. public Rasenmäher r;
  6. public int wert;
  7.  
  8.  
  9. public RasenmäherMischung1(Rasenmäher r, int wert)
  10. {
  11. this.r = r;
  12. this.wert = wert;
  13. }
  14.  
  15. public void run()
  16. {
  17. synchronized (r) {
  18. while(true)
  19. {
  20. r.setAktTank(wert*100);
  21. System.out.println("betanke Mischung 1: " + r.getAktTank());
  22. try {
  23. sleep(2000);
  24. } catch (InterruptedException e) {
  25. e.getStackTrace();
  26. }
  27. if(r.getAktTank() == r.getTank())
  28. break;
  29. r.notify();
  30. try {
  31. r.wait();
  32. } catch (InterruptedException e) {
  33. // TODO Auto-generated catch block
  34. e.printStackTrace();
  35. }
  36. }
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement