Does this setup: Thread runnable = new Thread() { @Override public void run() { try {…
- User
Does this setup: Thread runnable = new Thread() { @Override public void run() { try { com.supasulley.main.Main.main(args); } catch(Throwable t) { DMain.error(t.toString()); } }
code@Override public void setUncaughtExceptionHandler(UncaughtExceptionHandler eh) { DMain.error(eh.toString()); } }; runnable.setName("weeve"); runnable.start(); new DMain();... allow me to run DMain() and com.supasulley.main.Main.main(args); concurrently, on different, threads, where one process can't choke the other? - Assistant
Yes, the code snippet you provided allows you to run
DMainandcom.supasulley.main.Main.main(args)concurrently on different threads.The
Threadobject,runnable, is created with a custom implementation of theRunnableinterface. When you callrunnable.start(), it starts a new thread and executes the overriddenrun()method in that new thread. Inside therun()method, it callscom.supasulley.main.Main.main(args), which runscom.supasulley.main.Main.main(args)in a separate thread.Therefore, both
DMainandcom.supasulley.main.Main.main(args)will run concurrently on different threads, and one process cannot choke the other.