android - Async Task to Java equivalent -


i did in android year ago , wondering if possible convert java.

code android:

private void search() {     class getusers extends asynctask<void, void, string> {         progressdialog loading;          @override         protected string doinbackground(void... v) {             hashmap<string, string> params = new hashmap<>();             params.put(config.key_search, search);             requesthandler rh = new requesthandler();             string res = rh.sendpostrequest(config.url_search, params);             log.d("aaaa", "doinbackground: " + res);             return res;         }          /**          * after response given database          * @param s json string          */         protected void onpostexecute(string s) {             super.onpostexecute(s);             loading.dismiss();             showresult(s);         }          @override         protected void onpreexecute() {             super.onpreexecute();             loading = progressdialog.show(searchactivity.this, "searching", "wait sec", false, false);         }     }     getusers getusers = new getusers();     getusers.execute(); } 

its search sql database given parameter search.

any answers appreciated.

import java.util.concurrent.*;  executorservice executor = executors.newsinglethreadexecutor(); callable<string> task = new callable<>() {     public string call() {         system.out.println("before sleep");         timeunit.seconds.sleep(10);         system.out.println("after sleep");         return "foo";     } } future<string> future = executor.submit(task); timeunit.seconds.sleep(5); system.out.println("do stuff in parallel"); string result = future.get(); 

Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -