Android examples for java.lang:Thread
post Background Thread
//package com.java2s; import android.os.Handler; import android.os.Looper; public class Main { private static Handler sHandler; public static void postBackground(final Runnable run) { postBackgroundDelayed(run, 0);/*from w ww.ja va2 s .c o m*/ } public static void postBackgroundDelayed(final Runnable run, long delayMills) { if (run == null) return; getHandler().postDelayed(new Runnable() { @Override public void run() { Thread thread = new Thread(run); thread.start(); } }, delayMills); } public static void postDelayed(Runnable run, long delayMills) { if (run == null) return; getHandler().postDelayed(run, delayMills); } public static Handler getHandler() { if (sHandler == null) sHandler = new Handler(Looper.getMainLooper()); return sHandler; } }