java - Run 3 public voids in order (after each one has completed its task) -
i have 3 public voids. first void parse pdf file. second void enhance pdf file string , , third void uses string in order display textviews programmatically (in for-loop). when of these voids called, app crashes since they're trying run @ same time. want them wait each other complete task. don't wanna create single large void components in it.
how can call them wait each other finish?
try use runnable array
array:
runnable[] methods = new runnable[]{ new runnable() { @override public void run() { log.d("tag", "1"); //1 method } }, new runnable() { @override public void run() { log.d("tag", "2"); //2 method } }, new runnable() { @override public void run() { log.d("tag", "3"); //3 method } } }; call it:
executorservice service = executors.newsinglethreadexecutor(); (runnable r : methods) service.submit(r); service.shutdown();
Comments
Post a Comment