我使用了ThreadPoolExecutor.execute方法执行了两个MyThread类的对象,之后调用ThreadPoolExecutor.shutdown方法。这个方法不是等待提交的任务执行完才终止吗,为什么我提交的两个任务都没有被执行呢?
String adbHead = "adb ";
try {
if (EasyScreenshotAction.DevicePickerDialog.serial ==null || EasyScreenshotAction.DevicePickerDialog.serial.length()<1) {
//serial是序列号
}else {
adbHead="adb -s "+EasyScreenshotAction.DevicePickerDialog.serial+" ";
}
String mobileScreenshot=getCurrentTime()+"_screenshot.png";
String mobileXml=getCurrentTime()+"_xml.uix";
//使用多线程,来达到更快的同步速度
MyThread screenThread=new MyThread(adbHead+"shell /system/bin/screencap -p /data/local/tmp/"+mobileScreenshot);
//System.out.println(adbHead+"shell /system/bin/screencap -p /data/local/tmp/"+mobileScreenshot);
MyThread xmlThread=new MyThread(adbHead+"shell uiautomator dump /data/local/tmp/"+mobileXml);
//System.out.println(adbHead+"shell uiautomator dump /data/local/tmp/"+mobileXml);
monitor.setTaskName("Obtaining device screenshot");
monitor.subTask("Taking UI XML snapshot...");
ThreadPoolExecutor executor = new ThreadPoolExecutor(5,5, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
// Runtime.getRuntime().exec(adbHead+"shell /system/bin/screencap -p /data/local/tmp/"+mobileScreenshot).waitFor();
// System.out.println("截图执行完毕");
executor.execute(xmlThread);
// Runtime.getRuntime().exec(adbHead+"shell uiautomator dump /data/local/tmp/"+mobileXml).waitFor();
executor.execute(screenThread);
executor.shutdown();//启动关闭,执行原来提交的任务且不接受新的任务
请问我哪里出问题了呢?