Hi,
I have one single thread that i wish to start but whatever i try, i can't make it work. I start the thread in the main Class' constructor and call the constructor from main().
Here's a very cut down version:
My thread is not starting for some reason because "hey" is not shown in the command line.Code:public class TwoDWorld extends JPanel implements KeyListener, Runnable{
Thread t;
long startingTime = 0;
long passedTime = 0;
public TwoDWorld() {
t = new Thread();
t.start();
}
public static void main(String args[]) {
new TwoDWorld();
}
public void run() {
long startingTime = System.currentTimeMillis();
long totalTime = startingTime;
System.out.println("hey");
while (true) {
try {
passedTime = System.currentTimeMillis() - totalTime;
totalTime += passedTime;
update();
draw();
render();
t.sleep(50);
} catch (Exception e) {}
}
}
Any thoughts?
Thanks, James.
