In android development, asynchronous request data is often used. handler or AsyncTask is usually used. It is troublesome to use handler with message. The AsyncTask thread pool only allows 128 threads to work, there will be overflow problems (of course, there will not be so many threads working at the same time) So I wrote this code and looked at it with high fingers!
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 String KEY = "key"20 String TAG = "JQuery"21 N = 5;22 Executor worker = Executors.newFixedThreadPool(N);23 Handler handler = 2425 26 TaskListener listener =27 Object result =28 (listener !=293031323334 35 3637 38 execute( String url,39 worker.execute(4041 42 String result = 43 44 result =45 } 464748 49 Message msg = 50 Bundle data = 515253 msg.obj =5455565758 59 60 61 (worker != && worker 62 ExecutorService es =63 (!6465666768 69 70 7172 77 78 79 String get(String url) 80 InputStream inputStream = 81 StringBuilder strBuilder = 82 BufferedReader reader = 83 (String s = reader.readLine(); s != ; s =8485 8687 88899001 02 JQuery.execute("http://weather.news.qq.com/inc/minisite_125.js"0304 05 TextView t = TextView(TaskDemoActivity.0607 LinearLayout layout =080910 });