Here's my issue: I need the calling method terminate (otherwise my UI won't update itself), while the called method is still working. Atm it's something like this:
public InGameGUI() {
...
switchToRoboControl();
}
and switch ToRoboControl is supposed to execute a solution on the UI. I thought about using a custom Listener-thingee but 1. I have no idea how to do that properly and 2. I was wondering if there are better ways. Threads are also not really the way to go since there are several methods that I need to call this way...
I would use Threads
, this is precisely the use-case where they should be used.
Threads are also not really the way to go since there are several methods that I need to call this way...
And what stops you from starting and managing more Threads
and possibly grouping some tasks together?
Also, if you are allergic to many Threads you can define a heartbeat event (a single separate thread, which is periodically active (like started one instance each second)) which would always check and run the tasks to be running and you could schedule the tasks in your main thread.