java - Run a function synchronously in another thread -
how can run function synchronously in thread, meaning main ui thread has function calls function work on thread, waits new thread finish , returns value:
int mainfunction() //this function on main ui thread { return doworkonnewthread(); } int doworkonnewthread() { //do work on new thread }
you can use async task this, though it's asynchronous. can use callbacks onpostexecute , onprogressupdate update values needed. should note don't want synchronized block ui thread cause application not responding alert depending on how long calculation takes.
Comments
Post a Comment