From c6b3297af9c678751c6a183f4f655293c9e1d737 Mon Sep 17 00:00:00 2001 From: zgdgod <1092792570@qq.com> Date: Sat, 18 Jul 2020 21:27:58 +0800 Subject: [PATCH] Update 2_5_id.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主要是master_thread只进行了定义,没有赋值,进入main函数之后,才有master_thread_id; 其他就是加了一些输出,看起来直观一点 --- concurrency/concurrency_v1/chapter2/2_5_id.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/concurrency/concurrency_v1/chapter2/2_5_id.cpp b/concurrency/concurrency_v1/chapter2/2_5_id.cpp index 67b00d7..905aafb 100644 --- a/concurrency/concurrency_v1/chapter2/2_5_id.cpp +++ b/concurrency/concurrency_v1/chapter2/2_5_id.cpp @@ -27,8 +27,12 @@ void some_core_part_of_algorithm() { } int main() { - std::cout << std::this_thread::get_id() << endl; + master_thread = std::this_thread::get_id(); + std::cout << "master_thread: " << master_thread << endl; + cout << "master_thread 中运行:" << endl; + some_core_part_of_algorithm(); + cout << "thread 中运行:" << endl; thread t(some_core_part_of_algorithm); t.join(); return 0; -} \ No newline at end of file +}