?? threadpooltest.java
字號:
import java.util.concurrent.*;
/**
* Description:
* <br/>Copyright (C), 2008-2010, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee kongyeeku@163.com
* @version 1.0
*/
//實現Runnable接口來定義一個簡單的
class TestThread implements Runnable
{
public void run()
{
for (int i = 0; i < 100 ; i++ )
{
System.out.println(Thread.currentThread().getName()
+ "的i值為:" + i);
}
}
}
public class ThreadPoolTest
{
public static void main(String[] args)
{
//創建一個具有固定線程數(6)的線程池
ExecutorService pool = Executors.newFixedThreadPool(6);
//向線程池中提交2個線程
pool.submit(new TestThread());
pool.submit(new TestThread());
//關閉線程池
pool.shutdown();
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -