Back to project page PreCTS.
The source code is released under:
Apache License
If you think the Android project PreCTS 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 com.androidhuman.ctsprepare.util; /*ww w .j av a 2 s . c o m*/ import org.eclipse.swt.widgets.Display; public abstract class AsyncTask<T, U, V> { Thread thread; public final void execute(final T... params){ Display.getDefault().syncExec(new Runnable(){ public void run(){ onPreExecute(); } }); thread = new Thread(new Runnable(){ public void run(){ if(!Thread.currentThread().isInterrupted()){ final V result = doInBackground(params); Display.getDefault().syncExec(new Runnable(){ public void run(){ onPostExecute(result); } }); } } }); thread.start(); } public final void updateProgress(final U progress){ Display.getDefault().asyncExec(new Runnable(){ public void run(){ onProgressUpdate(progress); } }); } public void cancel(){ thread.interrupt(); } public abstract void onPreExecute(); public abstract V doInBackground(T... params); public abstract void onPostExecute(V result); public abstract void onProgressUpdate(U progress); }