How can port AsyncTask from Android to java?

Viewed 10474

AsyncTask is very useful to synchronized between UI thread and other threads in Android. So I have read its source code and tried porting to java classic (JDK) but no success because some classes don't exist in java (Message, Handler..).
I would like to create a class with some useful functions like AsyncTask (that can synchronized between main thread and other threads) :

    doInBackground(Params... params)
    onProgressUpdate(Progress... values)
    onPostExecute(Result result)
    publishProgress(Progress... values)
    onPreExecute()
    onCancelled()

Is there any way to try that?

3 Answers
Related