java - Callback from new thread to class from which thread was initiated -


i have class calling new thread.

public class mainclass{   private void cleardata() {                 // on separate thread                 new thread(new runnable() {                     @override                     public void run() {                         //do         //after notify mainclass thing has been done , pass value.          }       }      }    private void callbackfunc(int a){      // based on value of    } } 

i have function in mainclass. how call function new thread, receive callback. thanks.

you should able call method in mainclass name if calling directly inside mainclass (as opposed inner class).

if method name want call happens conflict 1 inner class has inherited object can prefix call mainclass.this, e.g. mainclass.this.tostring() calls tostring on mainclass, whereas tostring() calls on inner class instance.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -