Advertisement
Guest User

Untitled

a guest
Aug 27th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public class Check_services implements Runnable{
  2. List<Service> services;
  3. boolean running=true;
  4. public Check_services(List services)
  5. {
  6. this.services = services;
  7. }
  8.  
  9. @Override
  10. public void run()
  11. {
  12. while(running)
  13. {
  14. for(Service s : services)
  15. {
  16. if(!s.portIsOpen())
  17. {
  18. // fire Telegram Message
  19. }
  20. }
  21. try
  22. {
  23. Thread.sleep(10000);
  24. }
  25. catch (InterruptedException ex)
  26. {
  27. System.out.println("Error speep @ Check_services.class");
  28. ex.printStackTrace();
  29. }
  30. }
  31. }
  32.  
  33. public void startCheck()
  34. {
  35. checking = new Thread(new Check_services(services));
  36. checking.start();
  37. }
  38.  
  39. public void stopCheck() throws InterruptedException
  40. {
  41. if (!checking.isInterrupted())
  42. {
  43. checking.interrupt();
  44. checking.join();
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement