如果您正在使用基于Linux的系统,则可以使用 sched_getcpu() 打印当前线程所在的 CPU/核心编号 cout << "Thread running on Core " << sched_getcpu() <<endl