是复制线程安全吗?

编程入门 行业动态 更新时间:2024-10-15 12:37:41
本文介绍了是复制线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在C ++ 11方面,我是否认为在至少两个线程之间共享的价值语义对象的副本不是线程安全的?

解决方案

如果我们想在一个线程中获取一个大对象的副本,我们仍然需要一些同步机制来制作副本? div>

意味着如果我们想在一个线程中获取一个大对象的副本,我们还需要一些同步机制来进行复制吗?

是的。如果对象从其他线程访问(写入)并且要复制它,则必须确保访问同步。

In terms of C++11, am I correct in thinking that copy of value-semantic objects that is shared between at least two threads isn't thread safe?

Meaning that if we want to get a copy of an big object in a thread, we still need some synchronisation mecanism to make the copy?

解决方案

Meaning that if we want to get a copy of an big object in a thread, we still need some synchronisation mecanism to make the copy?

Yes. If the object is accessed (written to) from other threads and you want to copy it, you have to ensure the access is synchronized.

更多推荐

是复制线程安全吗?

本文发布于:2023-11-12 10:49:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581280.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:线程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!