Back to project page java_mega_api.
The source code is released under:
GNU General Public License
If you think the Android project java_mega_api listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/******************************************************************************* * Copyright (c) 2013 Dan Brough dan@danbrough.org. All rights reserved. * This program and the accompanying materials are made available under the * terms of the GNU Public License v3.0 which accompanies this distribution, * and is available at http://www.gnu.org/licenses/gpl.html * // w w w . j a v a 2s . c o m ******************************************************************************/ package org.danbrough.mega; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; public class ExecutorThreadPool implements ThreadPool { ScheduledExecutorService pool; boolean running = false; int initialSize = 11; public synchronized void start() { if (running) return; running = true; pool = Executors.newScheduledThreadPool(initialSize); } public int getInitialSize() { return initialSize; } public void setInitialSize(int initialSize) { this.initialSize = initialSize; } public synchronized void stop() { if (!running) return; running = false; pool.shutdownNow(); pool = null; } public void background(Runnable job) { if (!running) { return; } pool.execute(job); } public void background(Runnable callable, long delay, TimeUnit unit) { if (!running) { return; } pool.schedule(callable, delay, unit); } }