I have the following Java code:
public static void main(String[] args)
{
new Thread(new MyRunnable()).run();
showGUI();
}
My problem is that starting MyRunnable
blocks the main thread, causing showGUI
to not be called until it finishes running. What I'd like the program to do is spawn MyRunnable
and allow it to run independently in the background, enabling the main thread to forget about it and go ahead and do what it wants (like call showGUI
).
run
executes on the main thread. start
will create a new thread execution and execute it's run method on that thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With