[banting@localhost test]$ g++ -g --std=c++11 test84.cpp -lpthread -o test84
[banting@localhost test]$ gdb ./test84
GNU gdb (GDB) Red Hat Enterprise Linux 7.6.1-100.el7
Copyright (C)2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty"for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /home/banting/test/test84...done.
(gdb) b 23
Breakpoint 1 at 0x400ec0: file test84.cpp, line 23.
(gdb) r
Starting program: /home/banting/test/./test84
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
main thread id=0xf7fe2740
[New Thread 0x7ffff6fdb700 (LWP 1347067)]
child thread id=0xf6fdb700
hello world
hello world
Breakpoint 1, main () at test84.cpp:23
23 t.join();(gdb) info threads
Id Target Id Frame
2 Thread 0x7ffff6fdb700 (LWP 1347067)"WorkerThread" 0x00007ffff70c585d inwrite() at ../sysdeps/unix/syscall-template.S:81
* 1 Thread 0x7ffff7fe2740 (LWP 1347063)"MainThread" main () at test84.cpp:23
(gdb) quit
A debugging session is active.
Inferior 1[process 1347063] will be killed.
Quit anyway? (y or n) y
[banting@localhost test]$
[banting@localhost test]$ top -Hp 1347063top - 17:42:14 up 19 days, 17:18, 22 users, load average: 0.00, 0.01, 0.05
Threads: 2 total, 0 running, 0 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem :16268040 total, 2925428 free, 3114704 used, 10227908 buff/cache
KiB Swap: 8257532 total, 8254336 free, 3196 used. 12482396 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1347063 banting 200229961120912 t 0.00.00:00.00 MainThread
1347067 banting 200229961120912 t 0.00.00:00.00 WorkerThread