fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static String somestring = null;
  11.  
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14.  
  15. System.out.println("1. : " + somestring);
  16. new Thread(new Runnable(){
  17. public void run(){
  18. try{
  19. Thread.sleep(500);//fake doing the job
  20. } catch (Exception e){
  21. e.printStackTrace();
  22. }
  23. somestring = "set";
  24. System.out.println("2. : " + somestring);
  25. }
  26. }).start();
  27. System.out.println("3. : " + somestring);
  28. }
  29. }
Success #stdin #stdout 0.07s 380544KB
stdin
Standard input is empty
stdout
1. : null
3. : null
2. : set