Here you can find the source of executeInBackground(Runnable r)
public static synchronized void executeInBackground(Runnable r)
//package com.java2s; /*/* w ww . j a va2 s . c o m*/ * Copyright (C) 2008-2010 Igor Kriznar * * This file is part of GTD-Free. * * GTD-Free is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * GTD-Free is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with GTD-Free. If not, see <http://www.gnu.org/licenses/>. */ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; public class Main { private static ThreadPoolExecutor backgroundExecutor; public static synchronized void executeInBackground(Runnable r) { if (backgroundExecutor == null) { backgroundExecutor = new ThreadPoolExecutor(0, 1, 1, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setName("BackgroundExecutor"); //$NON-NLS-1$ t.setPriority(Thread.MIN_PRIORITY); t.setDaemon(false); return t; } }); } backgroundExecutor.execute(r); } }