狂吃cpu 导致程序很卡,除了线程睡眠
还有更好的办法吗
while (1) {
//int now = getTime();
//if (now - lastTime > 5) {
check(getResponseStr);
// lastTime = now;
//}
std::this_thread::sleep_for(seconds(10));
}
可不可以循环10次 释放1次这样,
可以用this thread yield释放线程时间片