Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. public void notifyEventChange(boolean change){
  2.  
  3. Runnable myRunnable = new Runnable() {
  4.  
  5. public void run() {
  6.  
  7. synchronized(this){
  8. try {
  9. // while(!Thread.currentThread().isInterrupted()){
  10. System.out.println("Entered thread wait");
  11. wait(duration);
  12. checkServerConnection();
  13. //}
  14. }
  15. catch(InterruptedException e){
  16. System.out.println(e);
  17. System.out.println("Interrupted request");
  18. }
  19. }
  20. }
  21. };
  22.  
  23. Thread th=new Thread(myRunnable);
  24. System.out.println("Entered thread module");
  25. if(change)
  26. {
  27. System.out.println(th.isInterrupted());
  28. System.out.println("Thread started");
  29. th.start();
  30. }
  31. else if(!change){
  32. System.out.println("Entered interrupted module");
  33.  
  34. th.interrupt();
  35. System.out.println(th.isInterrupted());
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement