c++ - Boost 开出来的线程怎么捕捉 Ctrl - c
PHP中文网
PHP中文网 2017-04-17 12:06:28
0
1
753

如题,我用 boost::thread 开了一个线程,线程就做循环打印吧。但是这个程序跑起来以后,按 ctrl-c,并不会立即退出,而要等挺长一段时间。

请问怎么使得这个线程能够马上响应呢?

PHP中文网
PHP中文网

认证0级讲师

reply all(1)
伊谢尔伦

ctrl+c will send a SIGINT signal. boost::thread may need to complete some resource cleanup work before exiting. You can also handle SIGINT yourself. However, it is not recommended to use signals. Use condition variables under Linux. Both MESSAGE and EVENT can do this under Windows. There is a better way to use condition variables in C++11 (boost’s thread library has entered the 11 standard)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!