Pass reference of object to a new Thread

后端 未结 4 378
天命终不由人
天命终不由人 2020-12-20 01:29

I have an object that contains a very large 3D-array of doubles and I need to start a new thread that need the data of this array, so I will either need to start a new threa

4条回答
  •  轮回少年
    2020-12-20 01:44

    To be more precise it's send by reference copy.

    Since this is a reference type, only a reference is copied in this case, and not all data.

    That's why you have to care about locking mechanisms in cases where more then one thread accesses the data this object refers to.

提交回复
热议问题