Java 线程池 ThreadPoolExecutor

1.

package com.task;

import java.io.File;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class SyncTreadPool extends ThreadPoolExecutor {

	public SyncTreadPool() {
		super(2, 4, 5, TimeUnit.SECONDS, new ArrayBlockingQueue<Runnable>(2000), new ThreadPoolExecutor.CallerRunsPolicy());
	}

	public static class Task implements Runnable {

		private Log log = LogFactory.getLog(this.getClass().getName());

		private SyncAllWhiteListFileTreadPool fileTreadPool;

		public Task(SyncAllWhiteListFileTreadPool fileTreadPool) {
			this.fileTreadPool = fileTreadPool;
		}

		@Override
		public void run() {
			// code

		}

	}
}

猜你喜欢

转载自xujava.iteye.com/blog/1939162