java - No messages are output from the second thread -
i have 2 threads:
//second thread private class init implements runnable { public void run() { settextmessage("initialization"); //perform actions } } //first thread private class download implements runnable { public void run() { settextmessage("downloading"); //perform actions thread thread = new thread(new init()); thread.start(); } } public void settextmessage(final string textmessage) { runonuithread(new runnable() { @override public void run() { if (dialog != null) { setdialogmessage(textmessage); } } }); } //add1 protected void setdialogmessage(dialog dst, string text) { if (dst != null) { textview progresstextdetails = (textview) dst.findviewbyid(r.id.progresstextdetails); progresstextdetails.settext(text); } } ideally, after starting second thread, see "initialization" instead "downloading" on screen , actions defined in second thread performed. message on screen not change. although actions defined in second thread started. method settextmessage called in second thread, text in ui thread not change. why?
your code correct , when start second thread second thread starts , in second thread have write code start first thread.
the first thread starts quick unable see downloading text , initialization appears suddenly.
try use log.e("tag", "downloading); in second thread know happens.
Comments
Post a Comment