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:
And if you like to do it the Java 8 way, you can do it as simple as this:
public class Java8Thread { public static void main(String[] args) { System.out.println("Main thread"); new Thread(this::myBackgroundTask).start(); } private void myBackgroundTask() { System.out.println("Inner Thread"); } }