set schedular-locking on / off
条件断点查看循环中的某些变量
break if命令
示例:break test.c:34 if (x & y) == 1
默认情况下我们执行到断点处继续执行时,所有线程都会运行。想要控制只有当前线程运行可用上面命令的on实现。
#include <iostream>
#include <thread>
#include <chrono>
void thread1func()
{
while(1)
{
std::cout << "this is thread1, ID: " << std::this_thread::get_id() << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
void thread2func()
{
while(1)
{
std::cout << "this is thread2, ID: " << std::this_thread::get_id() << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(1));
}
}
int main()
{
std::thread thd1(thread1func);
std::thread thd2(thread2func);
std::cout << "this is main thread" << std::endl;
thd1.join();
thd2.join();
return 0;
}