java - how to do something while you are waiting a Thread.join() -


i'm trying while thread waiting join() method want change name of button while waiting it's not working... , don't know why here's awful code:

 if( e.getsource()==botonfiltro ){             double [] datosfiltro2 = {                     (double.parsedouble(montotextfield.gettext())),//0monto                     (double.parsedouble(txtporcentaje.gettext())/100),//1porcentaje                     (double.parsedouble(txtprecio.gettext())),//2precio                     (double.parsedouble(txtrango.gettext())/100),//3rango                     (double.parsedouble(txtpmasduro.gettext())/100)//4pmasduro                     };             double [] datosfiltro1= {};             botonfiltro.settext("filtrando");             hilolanzarfiltro hilo = new hilolanzarfiltro(programa, datosfiltro1, datosfiltro2);             thread tfiltrando = new thread(hilo);             tfiltrando.start();             try { //              while(tfiltrando.isalive()){ //                  botonfiltro.settext("filtrando."); //                  thread.sleep(500); //                  botonfiltro.settext("filtrando.."); //                  thread.sleep(500); //                  botonfiltro.settext("filtrando..."); //                  thread.sleep(500); //              }                 tfiltrando.join();             } catch (interruptedexception e1) { //                           }             this.programa= hilo.getprograma();             string[] l = new string[programa.getcompañias().size()];             int i= 0;             for(compañia c: programa.getcompañias()){                 l[i++]=c.getsymbol();             }             jlistaprincipal.setlistdata(l);             lblcompaiasencontradas.settext("compa\u00f1ias encontradas: "+programa.getcompañias().size());             botonfiltro.settext("filtrar");          } 

the commented lines "thing" wanted do... thanks.

move changing label "tfiltrando" thread. * can either wait or execute tasks, never both.

*to honest, there 1 thing need understand: ui manipulation should done ui thread.

so suggest reading swingworker . should much.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -