java - for(;;) loop makes my applet unuseable -
here loop class:
public class timer {
private timer timer; private static boolean isrunning = true; public static void gameloop() { while(isrunning) //the loop { try { main.cash--; thread.sleep(2000); } catch (interruptedexception e) { // e.printstacktrace(); } } } }
when run applet, white screen, , cannot close applet, have use terminate button in eclipse.
while(isrunning=true) //the loop
...sets isrunning
true, returns true (whatever previous value of isrunning
was), , executes if statement. single = assignment, in case not want do.
you want use == instead:
while(isrunning==true) //the loop
or alternatively, more concisely (and preferably!) simply:
while(isrunning) //the loop
i assume isrunning
set false elsewhere in code, because there's nothing sets false here.
Comments
Post a Comment