Spring线程池配置

原文:http://blog.csdn.net/shimiso/article/details/8964527


Spring配置



	
	
	
	
	
	
	
	
	
	
		
	

Java代码

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.task.TaskExecutor;

public class ThreadPoolTest {
	@Autowired
	private TaskExecutor taskExecutor;// 线程池

	// 将创建的线程添加到线程池中
	public void test() throws Exception {
		for (int i = 0; i < 10; i++) {
			this.taskExecutor.execute(new AppContentDataPushThread());
		}
	}

	class AppContentDataPushThread implements Runnable {

		public AppContentDataPushThread() {
		}

		@Override
		public void run() {
			System.out.println("执行线程");
		}
	}
}

你可能感兴趣的:(旧分类)