是复制线程安全吗? [英] Is copy thread-safe?

查看:141
本文介绍了是复制线程安全吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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




解决方案

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


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


< blockquote>

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


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.

这篇关于是复制线程安全吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆