fork download
  1. class Ideone implements Runnable
  2. {
  3. public static void main(String[] args) {
  4. new Ideone().main();
  5. }
  6.  
  7. public void main(){
  8. Thread t= new Thread(this);
  9. display("Before start");
  10. t.start();
  11. display("After start");
  12. }
  13.  
  14. public void run(){
  15. int i;
  16.  
  17. try{
  18. display("In thread before sleep");
  19. Thread.sleep(1000);
  20. display("In thread after sleep");
  21. for(i=0;i<=5;i++){
  22. System.out.println(i);
  23. }
  24. display("In thread after loop");
  25. }
  26. }
  27. }
  28.  
  29. public void display(String msg)
  30. {
  31. System.out.println(System.currentTimeMillis() + ": " + msg);
  32. }
  33. }
  34.  
  35.  
Success #stdin #stdout 0.06s 380544KB
stdin
Standard input is empty
stdout
1382455550133: Before start
1382455550134: After start
1382455550134: In thread before sleep
1382455551134: In thread after sleep
0
1
2
3
4
5
1382455551135: In thread after loop