I want to spawn a Java thread from my main java program and that thread should execute separately without interfering with the main program. Here is how it should be:
This is another way of creating a thread using an anonymous inner class.
public class AnonThread { public static void main(String[] args) { System.out.println("Main thread"); new Thread(new Runnable() { @Override public void run() { System.out.println("Inner Thread"); } }).start(); } }