---
title: "Java中的线程池简单实现"
author: "pskfire"
date: "2012-11-22T21:46:01Z"
tags: []
categories: ["编程语言"]
slug: "java"
draft: false
lastmod: "2012-11-22T21:46:01Z"
id: 1733598
url: "https://pskfire.iteye.com/blog/1733598"
---

```java

package com.threadPool.executiveService;

public class MyThread implements Runnable{

	@Override
	public void run() {
		for(int i=0; i<100; i++) {
			System.out.println(Thread.currentThread().getName() + "i = " + i);
		}
	}

}

```



```java

package com.threadPool.executiveService;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ThreadPoolTest {

	public static void main(String[] args) {
		ExecutorService threadPool = Executors.newFixedThreadPool(6);
		threadPool.submit(new MyThread());
		threadPool.submit(new MyThread());
		threadPool.submit(new MyThread());
		threadPool.shutdown();
	}
}

```