Launch many programs using Thread and use join() to wait for the completion.
class Main2 { public static void main(String arg[]) { System.out.println("Main2"); } } public class Main { public static void main(String arg[]) throws Exception { System.out.println("Main"); Thread t1 = new Thread() { public void run() { Main2.main(new String[] {}); } }; t1.start(); t1.join(); System.out.println("Main again"); } }