I'm a little confused with multi threading in Java, I have a GUI which I created a thread for and another project which acts as a server and is used to receive data from other data sources which is on a separate thread. The server's thread calls a method in one of the views on the GUI thread and updates a status, however the GUI doesn't update. How can I setup this architecture correctly. Here's what I have:
public static void main(String[] args)
{
//Connections
Runnable r2 = new Runnable() {
@Override
public void run()
{
App.connectToServer();
}
};
//Launch main window
Runnable r1 = new Runnable() {
@Override
public void run()
{
//Installs theme
WebLookAndFeel.install();
//Launches main window
BootWindow myMainWindow = new BootWindow();
}
};
Thread thr1 = new Thread(r1);
Thread thr2 = new Thread(r2);
thr1.start();
thr2.start();
}
//Server connections
private static void connectToServer()
{
System.out.println("Connecting to the eTrade Manager Server..");
etmServer server = new etmServer();
server.connectEtmServer();
}