package common;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import send.service.TimeTask;
public class P6Main {
public static void main(String[] args) {
ExecutorService pool = Executors.newFixedThreadPool(3);
TimerThread1 t1 = new TimerThread1();
pool.execute(t1);
pool.shutdown();
}
}
class TimerThread1 extends Thread {
@Override
public void run() {
try {
// long time1 = Long.parseLong(FileCommon
// .getSystemConfigProperties("TIMEOUT"));
TimeTask.getTimer1(1);
} catch (NumberFormatException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
}
package send.service;
import java.io.File;
import java.io.IOException;
import java.util.Timer;
public class TimeTask {
public static void getTimer1(long time1) {
Timer timer = new Timer();
timer.schedule(new INXMLTask(), 1000, time1 * 60 * 1000);
}
static class INXMLTask extends java.util.TimerTask {
@Override
public void run() {
try {
String dir = "c:\\beifen\\";
File file = new File(dir);
File[] files = file.listFiles();
for(int i = 0 ;i < files.length;i ++){
if(files[i].exists()){
files[i].deleteOnExit();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
}