多线程扫描目录

package com.rdt.main;
import java.io.File;
import java.util.ArrayList;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;

import org.apache.log4j.Logger;

import com.rdt.thread.Producator;


public class Test_15 {
	
	static Logger logger = Logger.getLogger(Producator.class);
	static ArrayList urlList = new ArrayList();
	public static final int THREAD_POOL_SIZE = 20;          
	private final File POISON = new File("");
	private final BlockingQueue files = new LinkedBlockingQueue(40000);
	private final ConcurrentLinkedQueue infos = new ConcurrentLinkedQueue();
	private Thread[] pool = null;
	private volatile boolean running = false;
	
	public Test_15() {
		this(THREAD_POOL_SIZE);
	}
	
	public Test_15(int poolSize) {
		pool = new Thread[poolSize];
		FileWorker worker = new FileWorker();
		for(int i=0;i getInfos(){
		return infos;
	}
	
	public static void main(String[] args) {
		long a = System.currentTimeMillis();
		Test_15 instance = new Test_15();
		String strurl = "E:\\jygc\\webapp\\jobs\\box\\InDataPool";
		File folder = new File(strurl);//E:\\2013-09-13   E:\\jygc\\webapp\\jobs\\box\\InDataPool\\2013-09-19
		instance.addFilesIgnoreInterrupted(folder,0);
		instance.shutdown();
		instance.waiting();
		logger.info("读取所用时间:"+(System.currentTimeMillis() - a));
		logger.info(urlList.size()+"  "+urlList);

	}

}


你可能感兴趣的:(网络编程,JavaSE)