---
title: "Java 线程池 ThreadPoolExecutor"
author: "xuxujing"
date: "2013-09-09T15:24:03Z"
tags: []
categories: ["行业应用"]
slug: "java-threadpoolexecutor"
draft: false
lastmod: "2013-09-10T11:01:01Z"
id: 1939162
url: "https://xujava.iteye.com/blog/1939162"
---

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

		}

	}
}
```