fork download
  1. class MyRunnable implements Runnable
  2. {
  3. private static void doA() { System.out.println("A"); }
  4. private static void doB() { System.out.println("B"); }
  5.  
  6. public void run()
  7. {
  8. doA();
  9. if (Thread.currentThread().isInterrupted()) return;
  10. doB();
  11. }
  12. }
  13.  
  14. class Main
  15. {
  16. public static void main (String[] args) throws java.lang.Exception
  17. {
  18. new Thread(new MyRunnable()).start();
  19. }
  20. }
Success #stdin #stdout 0.04s 4452352KB
stdin
Standard input is empty
stdout
A
B