How to break while loop android server? -


this part of server's code. got problem, can't break endless loop. it's separate class, handle client connections. how it's possible make unlimited quantity of clients connected, finish connection on button click if it's possible?

public class handler implements runnable {  public void run(){ .... //sockets try{ .... //socket  while (true) {      client = server.accept();     count++;     log.d("my log", "connected");     log.d("my log", "log" + count);     executor.execute(new handler(client));          }     } }    

instead of using

while(true) 

use like

while(myconditional) {     client = server.accept();     count++;     log.d("my log", "connected");     log.d("my log", "log" + count);     executor.execute(new handler(client)); } 

where myconditional boolean value can set in ui thread, like

button.setonclicklistener(new view.onclicklistener() {     public void onclick(view v)     {         myconditional = false;     } }); 

Comments

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -