ITeye博客

Java 线程池 ThreadPoolExecutor

xuxujing · 2013-09-09 15:24 · JAVA · 行业应用 · Markdown

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

		}

	}
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。