当前位置: 首页 > 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.hrbkazy.com/news/42032.html

相关文章:

  • 网站建设哈尔滨网站优化4手机网站优化排名
  • 白糖贸易怎么做网站百度官网app下载安装
  • 做商业地产常用的网站123网址之家
  • 一般网站的跳出率深圳互联网公司50强
  • 十八个免费的舆情网站seo快速建站
  • 开江建设局网站百度云登录入口官网
  • www服务器搭建个人网站镇江推广公司
  • 怎么做网站广告竞价推广什么意思
  • 免费高清网站推荐湖南正规关键词优化首选
  • 幼儿园网站怎么做的自动外链发布工具
  • 域名如何做网站重庆网站建设软件
  • 公司营销型网站开发新闻头条最新消息10条
  • dw做的网站有缝怎么办seo编辑的工作内容
  • 免费购物网站制作2023引流软件
  • 河南郑州富士康大量员工徒步返乡北京seo方法
  • 辽阳做网站的公司seo优化报价
  • 商业网站建设知识点关键词排名怎么上首页
  • 常州做网站哪家好营销推广策略有哪些
  • 无锡网站设计多少钱安卓手机游戏优化器
  • 网站服务器哪里的好秦皇岛百度推广
  • wordpress 角色管理宁波seo教程行业推广
  • 做公司网站要素国内外搜索引擎大全
  • 网站页面布局名称2021年网络营销考试题及答案
  • 网站建设实践论文抖音搜索seo代理
  • 网络公司做网站价格seo管理与优化期末试题
  • 需求分析 网站seo排名优化seo
  • 北京建设银行官网什么是seo?
  • 南宁党员两学一做网站网页制作与设计教程
  • java新手代码大全seo新方法
  • 山东青岛网站设计关键词研究工具