<pre name="code" class="java"><span style="font-size:18px;">import java.util.ArrayList;
import java.util.List;
import com.company.interfacetest.FileScan;
import com.company.javaSE.uncompressfilegzip.UncompressFileGZIP;
public class FileManage {
public static void main(String[] args) {
// TODO Auto-generated method stub
List<String> list = FileScan.getFiles("D:/SoyaMessageUpload");
FileHandle fileHandle = new FileHandle(list, list.size());
fileHandle.setDesPath("D:/SoyaMessage");
Thread t1 = new Thread(fileHandle, "線程一");
Thread t2 = new Thread(fileHandle, "線程二");
Thread t3 = new Thread(fileHandle, "線程三");
Thread t4 = new Thread(fileHandle, "線程四");
t1.start();
t2.start();
t3.start();
t4.start();
List<Thread> tList = new ArrayList<Thread>();
tList.add(t1);
tList.add(t2);
tList.add(t3);
tList.add(t4);
for (int i = 0; i < tList.size(); i++) {
try {
tList.get(i).join();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("test");
}
}</span>
java子線程全部執行完畢執行主線程代碼
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.