标签:oid 线程等待 str BMI 多线程 join div submit exec
虽然项目用不上,先备份吧,控制多线程执行顺序有两种方法
1.通过join方法保证多线程的顺序性的特性
join:让主线程等待子线程结束后才能继续执行
public static void main(String[] args) throws InterrupterException { thread1.start(); thread1.join(); thread2.start(); thread2.join(); thread3.star(); }
2.
ExcutorService executor = Excutors.newSingleTheadExcutor():FIFO
static ExcutorService excutorService = Excutors.newSingleTheadExcutor(); public static void main(String[] args) throws InterrupterException { excutorService.submit(thread1); excutorService.submit(thread2); excutorService.submit(thread3); }
标签:oid 线程等待 str BMI 多线程 join div submit exec
原文地址:https://www.cnblogs.com/CuiHongYu/p/10048970.html