current position:Home>The thread to run up, feeling is bind to write wrong, but I don't know what wrong

The thread to run up, feeling is bind to write wrong, but I don't know what wrong

2022-08-06 16:03:07CSDN Q&A

#include #include#include#includeusing namespace std;class_mythread{public: void callback(int param) { for (int i = 0; i < 100; i++) { g_val++; this_thread::sleep_for(chrono::seconds(5)); } cout << "value:" << g_val << "thread id:" << this_thread::get_id() <<"Custom parameters are:"<public: int g_val = 0;};int main(){ _mythread th1; thread st(bind(&_mythread::callback,&th1,123 )); st.join(); system("pause");}

copyright notice
author[CSDN Q&A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/218/202207310003021655.html

Random recommended