daniele
daniele

Reputation: 21

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

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);

?

Upvotes: 2

Views: 81

Answers (1)

Tony the Pony
Tony the Pony

Reputation: 41357

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

Upvotes: 1

Related Questions