(gdb) i threads Id Target Id Frame * 1 Thread 0x7ffff7fcc740 (LWP 28904) "main" main () at main_01.cpp:22 2 Thread 0x7ffff77c2700 (LWP 28973) "main" 0x00007ffff78a7680 in __GI___nanosleep (requested_time=requested_time@entry=0x7ffff77c1ea0, remaining=remaining@entry=0x7ffff77c1ea0) at ../sysdeps/unix/sysv/linux/nanosleep.c:28 3 Thread 0x7ffff6fc1700 (LWP 28974) "main" 0x00007ffff78a7680 in __GI___nanosleep (requested_time=requested_time@entry=0x7ffff6fc0ea0, remaining=remaining@entry=0x7ffff6fc0ea0) at ../sysdeps/unix/sysv/linux/nanosleep.c:28 (gdb) watch a thread 3 Hardware watchpoint 3: a (gdb) c Continuing. [Switching to Thread 0x7ffff6fc1700 (LWP 28974)]
Thread 3 "main" hit Hardware watchpoint 3: a
Old value = 2 New value = 4 thread2_func (p_arg=0x55555555488d) at main_01.cpp:15 15 sleep(10);