使用带有pthread库的C ++语言支持Java线程之类的线程 [英] support a Thread like Java Thread using language C++ with the pthread library

查看:87
本文介绍了使用带有pthread库的C ++语言支持Java线程之类的线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我使用C ++语言在Linux上工作.但是在Linux上使用pthread C API很难工作,所以anyboy可以提供由c ++语言封装的开放代码,例如java Thread类!

谢谢!

解决方案

C ++ 0x(即将成为C ++ 11)在其规范中具有< thread>线程.仅提供该接口的标头.

Boost Thread是该标头的灵感来源,但是-为C ++ 03编写的-不再完全符合不断发展的标准.

不幸的是,并不是所有的编译器都支持(还)线程库. Boost本身将其Thread库更改为对0x规范更仿射",从而破坏了现有代码的一部分...

今天可能是最好的选择,但是不久的将来应该可以使用标准实现.
从实际的boost :: thread转移到std :: thread不应太复杂,所以...请继续关注! boost.org/doc/libs/1_47_0/doc/html/thread.html">boost的线程 [ 解决方案

C++0x (wll be C++11 soon) has in its specification a <thread> header that provides just that interface.

Boost Thread was the inspirer of that header, but -being written for C++03- does not fully comply anymore to the evolving standard.

Unfortunately not all the compilers support (yet) the thread library. Boost itself changed its Thread library to be more "affine" to the 0x specs, breaking part of preexisting code ...

Today is probably the best choice, but in a near future the standard implementation should be available.
Moving from the actual boost::thread to std::thread should not be complicated so ... stay tuned!


Have a look at boost''s Thread[^] library.


这篇关于使用带有pthread库的C ++语言支持Java线程之类的线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆