java - Exit while loop -


i wondering how exit while loop in class.

my "slave" app connected websocket through "master app". "slave app" checking if there new files in directory. for future, analyse these new files.

in slave app, i've got callback tells me if started/paused/stopped...

what have, launch loop method when "master app" started (via callback started?), stop loop when master app stopped ... and....

my loop class :

public class loop extends thread {     private boolean progisfinished;      public loop() {     }      public void run() {         try {             waitingforfiles();         } catch (exception e) {             // todo auto-generated catch block             e.printstacktrace();         }     }      public void waitingforfiles() throws exception {         progisfinished = false;         final file folder = new file("folder");          long sleepduration = 10000;         arraylist<file> newfilelist;          int counter = 0;         while (progisfinished != true) {             newfilelist = listlastmodifiedfiles(folder, sleepduration);             thread.sleep(sleepduration);         }     }      public static arraylist<file> listlastmodifiedfiles(file folder, long sleepduration) throws exception {         arraylist<file> newfilelist = new arraylist<file>();         // return new file         return newfilelist;     } } 

my main class :

private main(){     // read conf.xml , stores variables     readconfig();     if ( serverconnected ) {         // connect server via url         connect( serverurl );     } else         system.out.println("no conf or no connexion"); }  @override public void connectcallback() {     system.out.println("connected"); }  @override public void startcallback() {     // debug     system.out.println("simulation in progress");     loop = new loop(this);     try {         loop.start();     } catch (exception e) {         // todo auto-generated catch block         e.printstacktrace();     } }  @override public void stopcallback() {     // debug     system.out.println("simulation stopped"); } @override public void pausecallback() {     // debug     system.out.println("simulation in pause - wait resume");  } public static void main(string[] args) {            main main = new main();      } } 


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -