[root@centos concurrency_in_action]# ./example
terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted
Aborted
[root@centos concurrency_in_action]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 7145
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 7145
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
解决办法:包含<thread>头文件,编译时要加上 -lpthread
[root@centos concurrency_in_action]#
[root@centos concurrency_in_action]#
[root@centos concurrency_in_action]# g++ -std=c++11 example_2_1.cpp -o example -lpthread