腾讯云
开发者社区
文档
建议反馈
控制台
登录/注册
首页
学习
活动
专区
圈层
工具
MCP广场
文章/答案/技术大牛
搜索
搜索
关闭
发布
文章
问答
(9999+)
视频
沙龙
1
回答
std
::
thread
和
std
::
endl
无
预期
输出
、
我正在尝试C++11 threads中
的
一些示例,我看到了一些令人惊讶
的
结果。使用以下代码#include <
thread
>
std
::cout << "Hello concurrent world);
std
::
thread
fn_obj_th(bt); fn_obj_
浏览 0
提问于2012-04-23
得票数 1
回答已采纳
1
回答
如何通过线程获取c++中
的
父id?
、
、
、
我想知道如何从创建
的
线程中获取父id。我
的
想法是在main函数中创建一个id变量,并在创建线程时将其作为参数提供,但它不起作用。或者我能以其他方式获得家长id吗?我
的
代码://do something}
std
::
thread
::id id =
std
:
浏览 6
提问于2021-05-26
得票数 0
3
回答
将一个向量分解成几乎相等
的
子向量,然后存储到另一个向量中。
、
、
、
thread
_amount) {
std
::cout << r << " need to
浏览 0
提问于2020-08-08
得票数 0
回答已采纳
1
回答
在C++中执行非阻塞线程
我遇到
的
问题是,如果我添加th.join(),主程序在线程结束之前不会继续运行。如果
没有
.join(),程序就会崩溃。<
std
::
endl
;
std
::cou
浏览 29
提问于2020-05-23
得票数 1
回答已采纳
2
回答
带有
std
::
endl
的
C++多线程程序I/O问题
、
、
我试着学习如何使用C++11线程库,然后,我对下面代码
的
输出
感到困惑。
std
::cout << "Inside
Thread
:: ID = " <<
std
::this_
thread
::get_id() <<
std
::
endl
;{()<<
std
::
endl
;
std
::cout<<
浏览 0
提问于2019-01-10
得票数 0
回答已采纳
1
回答
带有数据副本
的
C++线程问题
、
我正在尝试一个使用gcc头7.0.0 20161020
和
c+1z
的
简单线程程序。
std
::
thread
t1 {tsk1};
std
::
thread
t3(&Task"<<
std
::
endl
;} 它
的
输出<
浏览 3
提问于2016-10-21
得票数 1
回答已采纳
4
回答
C++ 11线程简单示例
、
、
、
我是c++
的
新手,我正在研究一些c++跨平台线程教程。function will be called from a
thread
std
::cout << "Launched by
thread
" << tid <<
std
::
endl
;
std
::
thread
t
浏览 9
提问于2013-12-30
得票数 19
回答已采纳
1
回答
线程中不一致
的
thread
_local变量
、
、
::cout << "model " <<
std
::this_
thread
::get_id() << " " << &TRIALS::a << " " << TRIALS::a <<
std
::
endl
return 0;我只是运行一个线程进行调试,但这是
输出
:主140279012532800 0x7f9540b621
浏览 1
提问于2019-10-07
得票数 3
回答已采纳
1
回答
未来
和
承诺机制
的
用法
= a + b;} char str[10] = "Abc";
std
::cout << "From inside the
浏览 18
提问于2020-09-05
得票数 0
回答已采纳
1
回答
c++0x中线程间
的
异常传播
、
、
我使用
的
是gcc 4.5,我想把一个异常转移到另一个线程:#include <iostream> { e =
std
::current_exception();
浏览 0
提问于2011-03-29
得票数 2
回答已采纳
1
回答
对于不同
的
中断点,Boost::
thread
::interrupt()
的
行为是不同
的
。为什么?
、
、
、
我目前正在编写一个使用boost线程
的
DLL。我在使用boost::
thread
::interrupt()
和
捕获
thread
_interrupted异常时遇到了问题。我已经写了一个基本
的
例子来阐明我
的
观点,它在这篇文章
的
底部 程序启动一个线程,该线程使用一个worker函数,每个worker函数都有一个不同
的
中断点。当用户按enter时,线程被中断,程序关闭。对于我尝试过
的
所有中断点(除了interruption_point()),我
浏览 0
提问于2013-10-07
得票数 1
1
回答
std
::condition_variable线程争用
、
、
、
我有一个问题,我
的
condition_variables似乎不能互相通知。也就是说,我下面的代码在等待
和
通知线程中都使用了互斥锁,但仍然不能正确运行。谢谢。<< "one" <<
std
::
endl
;{
std
::unique_lock<
std
::mutex > lock { m_one };cv_one.wait( lock );
std
浏览 0
提问于2014-06-25
得票数 0
2
回答
调用重置后不会删除unique_ptr
、
" <<
std
::
endl
; }<<
std
::
endl
;
std
::this_
thread
::sleep_for(
std
::chrono::seconds(5));
std</
浏览 3
提问于2021-06-07
得票数 0
回答已采纳
1
回答
与GCC一起使用C++11中
的
线程作用域对象
、
、
、
考虑以下C++11程序: S() {/* do something */ }} 我还
没有
要测试
的
GCC 4.8,但是从我读到
的
关于C++11标准
的
内容来看,无论我是否将全局对象声明为
thread
_local,对于在程序执行期间可以创建
的
所有可能
的
线程,对象本身都将被实例化一次。在GCC中,有
没有
办法(不管是不是可移植
的
)让全
浏览 0
提问于2013-07-04
得票数 0
回答已采纳
2
回答
为什么
std
::cout在线程中被抢占,而printf却
没有
?
、
、
我开始学习C++11标准中
的
线程,我正在尝试一个非常基本
的
程序,它创建10个线程,加入它们,然后退出。在线程函数中,我试图打印正在创建线程
的
for循环
的
索引,如下所示:for(int i = 0; i < 10; i++) {threads.push_back(
std
::
thread
([i](){ printf("
Thread</
浏览 3
提问于2014-11-02
得票数 3
回答已采纳
3
回答
从父类调用派生成员函数
、
、
、
我得到
的
是“纯粹
的
虚拟方法”。我该怎么做?protected: } virtual void f() =
浏览 1
提问于2021-09-01
得票数 2
回答已采纳
2
回答
为什么程序不能在堆栈展开后达到适当
的
返回指令?
、
、
、
、
>struct Object{
std
:DoSomeWork() {
std
::
thread
AnotherTh(&Object::GenerateException ,this);}int main(){ Object ins
浏览 1
提问于2020-05-02
得票数 2
回答已采纳
1
回答
条件变量
的
.wait_for()是在特定时间间隔内执行后台任务
的
有效方法吗?
、
以前我有一个
std
::
thread
,它每秒循环一次,检查是该运行活动
的
时间还是程序关闭
的
时间。这允许我在任何时候关闭程序,而不需要活动线程上
的
.join()阻止应用程序
的
退出等待它
的
下一次迭代。
endl
; // This is where the rest of the program wou
浏览 0
提问于2018-09-28
得票数 0
回答已采纳
1
回答
如何摆脱“
std
::WinAPI::id”与"WinAPI线程-id“(在Windows上)相同
的
id?
、
、
、
、
如何从
std
::
thread
::id中获得与"Win线程- id“相同
的
id(在Windows上)?线程id为9120 (id
和
this_id).我尝试了几种ANSI C++方法,但是它们产生了一个不同
的
id:代码:{ const::
thread
::id this_id =
std
::this_
thread
::get_id(); /
浏览 7
提问于2022-05-16
得票数 1
回答已采纳
1
回答
std
::atomic<
std
::string>是否正常工作?
、
、
、
我正在阅读Anthony Williams
的
“在行动中
的
C++并发”
和
第5章,其中讨论了新
的
多线程感知内存模型
和
原子操作,他说: #inc
浏览 2
提问于2013-06-01
得票数 57
回答已采纳
点击加载更多
相关
资讯
C+标准库 std:thread 的简单使用,一文搞定还不简单?
std:io:BufReader 对象借用和引用的问题
C++20:核心语言
如何学好C+。有书自学就够吗?那你可能就还是在入门!
从零开始学习C+编程——数据计算
热门
标签
更多标签
云服务器
ICP备案
实时音视频
即时通信 IM
对象存储
活动推荐
运营活动
广告
关闭
领券