Trigger main thread method from secondary thread?
Okay, I have a program, and it needs to connect to a very, very laggy server to get data. Without threading, the entire UI will hang during this lag. So, I've made threads that grab the data, and put said data into variables the entire program can access.
However, I have a dilemma. Once that data is stored, the program must do things with it. However, it can not do said things from the secondary thread, and the main thread can not sit around waiting for the data to be ready for any length of time.
As an analogy, if you have any kind of email notification popup anywhere, think of the email system as a secondary thread and whatever you do throughout the day as the main thread. You certainly don't sit around and do nothing waiting for an email, but when you see the popup, you run the appropriate method (ie. go check your email).
The best solution I see is if the thread, after moving data where it has to go, could send some sort of trigger - very, very much like a button press - that would alert the main thread to divert into a processing method.
The most obvious (if perhaps unorthodox) way to accomplish this would be to actually create some form of action event and trigger it from the thread, but as best I can tell, that specifically requires calling actionPerformed(), and any method called from a thread is apparently run inside the thread its self, which would be bad.
Does anyone have any application-independent advice on this?