线程学习【八】 join办法guojizaixian - 娱乐之横扫全球

线程学习【八】 join办法guojizaixian

2019-02-08 08:25:01 | 作者: 晨濡 | 标签: 线程,运转,资源 | 浏览: 4680


把 try catch注释掉,运转作用如下(两个线程替换抢占cpu资源):
Thread-0.......0
Thread-0.......1
Thread-1.......0
Thread-1.......1
Thread-1.......2
Thread-0.......2
Thread-1.......3
Thread-0.......3
Thread-0.......4
Thread-0.......5
Thread-0.......6
Thread-0.......7
Thread-0.......8
Thread-0.......9
Thread-1.......4
Thread-1.......5
Thread-1.......6
Thread-1.......7
Thread-1.......8
Thread-1.......9


假如线程 t1 start后调用了 t1.join(),运转作用如下(t1线程先运转完,然后运转t2线程):
Thread-0.......0
Thread-0.......1
Thread-0.......2
Thread-0.......3
Thread-0.......4
Thread-0.......5
Thread-0.......6
Thread-0.......7
Thread-0.......8
Thread-0.......9
Thread-1.......0
Thread-1.......1
Thread-1.......2
Thread-1.......3
Thread-1.......4
Thread-1.......5
Thread-1.......6
Thread-1.......7
Thread-1.......8
Thread-1.......9
版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表娱乐之横扫全球立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章