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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -