fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class DodajOdejmij implements Runnable {
  5. public int i = 0;
  6.  
  7. synchronized void dodajOdejmij(){
  8. for(int j=0;j<3;j++){
  9. i++;
  10. System.out.print(i);
  11. try {
  12. Thread.sleep(100);
  13. } catch (InterruptedException e) {
  14. e.printStackTrace();
  15. }
  16. i--;
  17. System.out.print(i);
  18. }
  19. }
  20. public void run() {
  21. dodajOdejmij();
  22. }
  23. }
  24.  
  25. public class Main {
  26.  
  27. public static void main(String args[]) {
  28. DodajOdejmij x = new DodajOdejmij();
  29. new Thread(x).start();
  30. new Thread(x).start();
  31. new Thread(x).start();
  32. }
  33. }
  34.  
Success #stdin #stdout 0.06s 216512KB
stdin
Standard input is empty
stdout
101010101010101010