I'm using threads for the first time in Java. Let me know what here is causing an infinite loop and how I can resolve it. I think the issue is being caused by the fact that I'm using a GUI along with threading.
What happens is that infinite copies of the GUI pop up.
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new RollplayGUI();
}
});
}
public RollplayGUI() {
createGUI();
RollplayGUI rg = new RollplayGUI();
Thread trg = new Thread(rg);
trg.setDaemon(true);
trg.run();
}
public void run() {
//Some fun stuff my daemon thread is supposed to do
}
The reason I'm doing this is that the run() method does some net code that blocks until it gets a connection from another program.