Re: Thread Help required maybe...
TheBigPJ wrote:
Im looking for advice on the best way to keep my screen program
updating every second as well as being able to cope with mouse and
keyboard input.
I keep looking at threads, and see that I could implement my main
ServerSide class.
Am I correct in thinking that the following main and run method below
would run at the same time? Run is just their to allow it to branch
out,
The run() method will start sometime after the start() call on the thread, and
the main thread will end around the same time, more or less.
public class HelloRunnable implements Runnable {
public void run() {
System.out.println("Hello from a thread!");
}
public static void main(String args[]) {
(new Thread(new HelloRunnable())).start();
}
}
I was either going to go for threads or a game-loop idea, any advice?
You need to move your GUI initialization off the main thread, where it is now,
and into the Event Dispatch Thread (EDT). The Java tutorial mentions this.
--
Lew