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

网站上传后打不开网络seo营销推广

网站上传后打不开,网络seo营销推广,阿里云做网站的代码,网络团队C之thread_local变量_c threadlocal-CSDN博客 thread_local简介 thread_local 是 C11 为线程安全引进的变量声明符。表示对象的生命周期属于线程存储期。 线程局部存储(Thread Local Storage,TLS)是一种存储期(storage duration),对象的存储是在…

C++之thread_local变量_c++ threadlocal-CSDN博客

thread_local简介
        thread_local 是 C++11 为线程安全引进的变量声明符。表示对象的生命周期属于线程存储期。

        线程局部存储(Thread Local Storage,TLS)是一种存储期(storage duration),对象的存储是在线程开始时分配,线程结束时回收,每个线程有该对象自己的实例;如果类的成员函数内定义了 thread_local 变量,则对于同一个线程内的该类的多个对象都会共享一个变量实例,并且只会在第一次执行这个成员函数时初始化这个变量实例。

        thread_local 一般用于需要保证线程安全的函数中。本质上,就是线程域的全局静态变量。
———————————

std::mutex print_mtx;    //避免打印被冲断thread_local int thread_count = 1;
int global_count = 1;void ThreadFunction(const std::string& name, int cpinc)
{for (int i = 0; i < 5; i++){std::this_thread::sleep_for(std::chrono::seconds(1));std::lock_guard<std::mutex> lock(print_mtx);std::cout << "thread name: " << name << ", thread_count = " << thread_count << ", global_count = " << global_count++ << std::endl;thread_count += cpinc;}
}int main()
{std::thread t1(ThreadFunction, "t1", 2);std::thread t2(ThreadFunction, "t2", 5);t1.join();t2.join();
}输出:thread name: t2, thread_count = 1, global_count = 1
thread name: t1, thread_count = 1, global_count = 2
thread name: t1, thread_count = 3, global_count = 3
thread name: t2, thread_count = 6, global_count = 4
thread name: t1, thread_count = 5, global_count = 5
thread name: t2, thread_count = 11, global_count = 6
thread name: t1, thread_count = 7, global_count = 7
thread name: t2, thread_count = 16, global_count = 8
thread name: t1, thread_count = 9, global_count = 9
thread name: t2, thread_count = 21, global_count = 10

可以看出来每个线程中的 thread_count 都是从 1 开始打印,这印证了 thread_local 存储类型的变量会在线程开始时被初始化,每个线程都初始化自己的那份实例。另外,两个线程的打印数据也印证了 thread_count 的值在两个线程中互相不影响。作为对比的 global_count 是静态存储周期,就没有这个特性,两个线程互相产生了影响。
—————————————

http://www.tj-hxxt.cn/news/15063.html

相关文章:

  • 廉洁 网站建设下载百度网盘
  • 网站建设怎样找客户设计公司企业网站
  • 做网站签合同百度关键词搜索排名统计
  • 德州哪里做网站专业seo整站优化
  • 北京出名做网站的公司婚恋网站排名前十名
  • 网站开发相关技术百度怎么优化网站排名
  • 整站seo怎么做沙坪坝区优化关键词软件
  • 设计企业展厅的公司成都网站快速优化排名
  • 做网站前台要学什么课程移动优化课主讲:夫唯老师
  • 做ic比较有名的网站广州网络推广专员
  • 品牌创意网站公司网页网站建设
  • 欧洲美妇做爰网站外贸营销策略都有哪些
  • 电子商务网站建设 市场分析seo提升排名
  • 网站一般怎么维护江苏网站建设推广
  • 越南做网站服务器百度秒收录技术
  • 多语言企业网站源码网络推广外包公司
  • 中国风网站配色方案百度开户需要什么资质
  • 使用腾讯云建设网站教程广告多的网站
  • 搅拌机东莞网站建设技术支持重庆网站建设软件
  • 中山建网站咨询电话关于手机的软文营销
  • 东莞网站建设排名 南城泰安网站seo
  • 网站 的空间网站外链购买平台
  • 招商加盟网站建设目的app引导页模板html
  • 南昌网站建设 南昌做网站公司seo优化在哪里学
  • 动漫网站源码免费3a汽车集团公司网络营销方案
  • 石家庄网站建设加王道下拉张家界百度seo
  • 网站建设那里好seo原创工具
  • 企业网站设计需要多久中国北京出啥大事了
  • 网站页面做专题的步骤长沙推广公司
  • 有个印度做网站的天天找我清远今日头条最新消息