knightforyou / testcyber

0 stars 0 forks source link

多线程编程-C++ #11

Open knightforyou opened 6 months ago

knightforyou commented 6 months ago

C++11多线程-【1】创建线程的三种方式 https://cloud.tencent.com/developer/article/1820729 【C/C++调整线程优先级】 https://blog.csdn.net/weixin_43273308/article/details/130119620
C++ 多线程 https://www.runoob.com/cplusplus/cpp-multithreading.html

knightforyou commented 6 months ago

1、C++基础知识 2、C++11 3、《C++并发编程实战》的读书笔记:https://github.com/xuyicpp/multi_threading 1.7看完 int newprio = 97; pthread_attr_t attr; int policy = SCHED_RR; sched_param periorityParam; periorityParam.sched_priority = newprio;

pthread_attr_init(&attr);
pthread_attr_setschedpolicy(&attr, policy);
pthread_attr_setschedparam(&attr, &periorityParam);
pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
pthread_t thread_handle = t_.native_handle();
pthread_setschedparam(thread_handle, policy, &periorityParam);
t_.join();

std::thread 没有直接设置优先级的函数 https://blog.csdn.net/weixin_43273308/article/details/130119620 https://l2m2.top/2022/03/18/2022-03-18-thread-in-cplusplus/ 十分钟掌握C++中std::thread的基础用法