java子线程全部执行完毕执行主线程代码

来源:互联网 发布:淘宝拍照灯光 编辑:程序博客网 时间:2024/06/05 02:51
<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 stubList<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>


                                             
0 0
原创粉丝点击