Advertisement
Guest User

Untitled

a guest
Feb 27th, 2015
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. class Test1{
  2.  
  3. static class a extends Thread{
  4. public void run(){
  5. f();
  6. }
  7.  
  8. }
  9. static class b extends Thread{
  10. public void run(){
  11. g();
  12. }
  13.  
  14. }
  15.  
  16. public static synchronized void f(){
  17. int i =0;
  18.  
  19. while(true){
  20. System.out.println("Hello" + i++);
  21. }
  22. }
  23. public static synchronized void g(){
  24. int i =0;
  25.  
  26. while(true){
  27. System.out.println("GoodBye"+ i++);
  28. }
  29. }
  30.  
  31. public static void main(String[] args){
  32. new a().start();
  33. new b().start();
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement