当前位置: 首页 > news >正文

苏州网站建设与网络推广现在市场最火的网店平台

苏州网站建设与网络推广,现在市场最火的网店平台,手机wap网站用什么语言开发,可信网站服务转自#xff1a;http://www.cnblogs.com/haippy/p/3236136.html 上一篇博客《C11 并发指南一(C11 多线程初探)》中只是提到了 std::thread 的基本用法#xff0c;并给出了一个最简单的例子#xff0c;本文将稍微详细地介绍 std::thread 的用法。 std::thread 在 threadhttp://www.cnblogs.com/haippy/p/3236136.html 上一篇博客《C11 并发指南一(C11 多线程初探)》中只是提到了 std::thread 的基本用法并给出了一个最简单的例子本文将稍微详细地介绍 std::thread 的用法。 std::thread 在 thread 头文件中声明因此使用 std::thread 时需要包含 thread 头文件。 std::thread 构造 default (1) thread() noexcept;initialization (2) template class Fn, class... Args explicit thread (Fn fn, Args... args);copy [deleted] (3) thread (const thread) delete;move (4) thread (thread x) noexcept; (1). 默认构造函数创建一个空的 thread 执行对象。(2). 初始化构造函数创建一个 thread对象该 thread对象可被 joinable新产生的线程会调用 fn 函数该函数的参数由 args 给出。(3). 拷贝构造函数(被禁用)意味着 thread 不可被拷贝构造。(4). move 构造函数move 构造函数调用成功之后 x 不代表任何 thread 执行对象。注意可被 joinable 的 thread 对象必须在他们销毁之前被主线程 join 或者将其设置为 detached. std::thread 各种构造函数例子如下参考 #include iostream #include utility #include thread #include chrono #include functional #include atomicvoid f1(int n) {for (int i 0; i 5; i) {std::cout Thread n executing\n;std::this_thread::sleep_for(std::chrono::milliseconds(10));} }void f2(int n) {for (int i 0; i 5; i) {std::cout Thread 2 executing\n;n;std::this_thread::sleep_for(std::chrono::milliseconds(10));} }int main() {int n 0;std::thread t1; // t1 is not a threadstd::thread t2(f1, n 1); // pass by valuestd::thread t3(f2, std::ref(n)); // pass by referencestd::thread t4(std::move(t3)); // t4 is now running f2(). t3 is no longer a threadt2.join();t4.join();std::cout Final value of n is n \n; } move 赋值操作 move (1) thread operator (thread rhs) noexcept;copy [deleted] (2) thread operator (const thread) delete; (1). move 赋值操作如果当前对象不可 joinable需要传递一个右值引用(rhs)给 move 赋值操作如果当前对象可被 joinable则 terminate() 报错。(2). 拷贝赋值操作被禁用thread 对象不可被拷贝。 请看下面的例子 #include stdio.h #include stdlib.h#include chrono // std::chrono::seconds #include iostream // std::cout #include thread // std::thread, std::this_thread::sleep_forvoid thread_task(int n) {std::this_thread::sleep_for(std::chrono::seconds(n));std::cout hello thread std::this_thread::get_id() paused n seconds std::endl; }/** FUNCTION * Name: main* Description: program entry routine.* */ int main(int argc, const char *argv[]) {std::thread threads[5];std::cout Spawning 5 threads...\n;for (int i 0; i 5; i) {threads[i] std::thread(thread_task, i 1);}std::cout Done spawning threads! Now wait for them to join\n;for (auto t: threads) {t.join();}std::cout All threads joined.\n;return EXIT_SUCCESS; } /* ---------- end of function main ---------- */ 其他成员函数 get_id 获取线程 ID。joinable 检查线程是否可被 join。join Join 线程。 detach Detach 线程 swap Swap 线程 。 native_handle 返回 native handle。 hardware_concurrency [static] 检测硬件并发特性。
http://www.yutouwan.com/news/255060/

相关文章:

  • 广州建设职业培训学校徐州百度搜索优化
  • 聊城做网站的公司咨询网站制作与网站建设技术
  • 网站建设部署与发布答案网站建设需要哪些东西
  • 网站建设手机站wordpress 企业主模板
  • 黄页网站推广公司html做网站自适应宽度
  • 外贸网站建设平台wordpress4.6教程
  • 做营销型网站织梦网站下载地址
  • 搭建网站难吗做一个网页容易吗
  • 腾讯云win建设网站企业简介ppt范文大全免费
  • 大型网站开发像天猫类的seo公司品牌哪家好
  • 电脑网站微信支付怎么做的外国做挂的网站是多少
  • 做网站的硬件西安高端品牌网站
  • 公主岭网站建设电商网站商品属性设计
  • 外国平面设计网站网站建设空间是否续费
  • 网站优化网站建设公司四川省网站建设
  • 北京定制网站建设企业创建网站
  • 黄岩网站建设企业网页建设公司咨询电话
  • 网页制作与网站开发网站关键字挖掘
  • 网站的三大因素seo排名工具外包
  • php网站开发工程师岗位职责蒙城网站建设
  • 深圳网站维护公司大学城网站开发公司电话
  • 专业网站建设企业网站制作wordpress 如何回到初始化
  • 肇庆网站建设方案优化怎么搭建属于自己的网站
  • 企业商城网站开发网站建设后台 手工上传
  • 兰溪网站建设学徒免费域名申请入口
  • 文本文档做网站学校网站开发需求
  • 租房网站模板在线制图免费版
  • 怎么建设自己的购物网站工信部网站备案用户名
  • php网站开发个人简历晚上必看的正能量网站
  • 上海专业网站建设排行wordpress怎么修改模板文件