Back to project page cpustats.
The source code is released under:
Apache License
If you think the Android project cpustats listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package jp.takke.cpustats; /*from ww w .j av a2 s.co m*/ import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.concurrent.Executor; import android.os.AsyncTask; public abstract class MyAsyncTask<Params, Progress, Result> extends AsyncTask<Params, Progress, Result> { @SuppressWarnings("unchecked") public final AsyncTask<Params, Progress, Result> parallelExecute(Params... params) { if (android.os.Build.VERSION.SDK_INT >= 13) { // Android 3.2 ??????????????????????????????????????????????????? // @see http://daichan4649.hatenablog.jp/entry/20120125/1327467103 // ?????? Android 1.6 ??????????????????????????????????????????? // return super.executeOnExecutor(executor, params); try { final Field f = AsyncTask.class.getField("THREAD_POOL_EXECUTOR"); final Executor executor = (Executor) f.get(null); final Method m = this.getClass().getMethod("executeOnExecutor", new Class[]{ Executor.class, Object[].class }); return (AsyncTask<Params, Progress, Result>) m.invoke(this, executor, params); } catch (Exception e) { MyLog.e(e); } } return super.execute(params); } }