开发者

Copy the reference of an object or pass it in a method/constructor is thread safe?

开发者 https://www.devze.com 2023-03-19 01:33 出处:网络
开发者_JS百科I have an object that is shared in read/write between threads. Assuming that the synchonization is correctely done, if A is the object previously initialized when no threads are running,

开发者_JS百科I have an object that is shared in read/write between threads.

Assuming that the synchonization is correctely done, if A is the object previously initialized when no threads are running, when they start working is thread-safe do:

Object B = A;

DoSomething(A);

?


References can safely be shared; however, access to the actual object may require synchronization.

0

精彩评论

暂无评论...
验证码 换一张
取 消