1.執(zhí)行器Excutor
newCachedThreadPool:按需創(chuàng)建線程
newFixedThreadPool:創(chuàng)建指定多個線程
newSingleThreadExcutor:創(chuàng)建單個線程
newScheduledThreadPool
newSingleThreadExcutor
步驟:Excutors.newCachedThreadPool();
submit()提交Runaable/Callable對象;
接收保存Future對象用以停止線程,提交Callable對象代承;shutDown關(guān)閉線程池枫笛;
2.ForkJoin框架