線程的執(zhí)行時機 線程在其對象被創(chuàng)建后立即執(zhí)行。 等待線程和分離線程 線程創(chuàng)建后通過調(diào)用thread對象的join()或detach()函數(shù)決定線程是等待還是分離; 不能對沒有執(zhí)行線程的thread對象使用join()或detach(); 使用join()或detach()之前應對thread對象進行
Read More
以上代碼中就包含兩個線程:“主線程”、“t線程”。主線程入口函數(shù)為“main”而t線程入口函數(shù)為“hello”。t.join()保證了主線程會等待t線程及其相關(guān)線程。
Read More