Suppose I have an immutable class, but I can't actually make all my
fields final. What is the next best way to safely publish that class
to other threads. Is it simply something like this at the end of my
constructor:
synchronized (this) {}
Is there anything more efficient?
Another point I am a bit confused about is how safe publishing works
with a tree or graph of objects. Suppose I have a linked list of
objects such as:
a -> b -> c -> d
If I wish to safely publish that data structure to other threads, do I
only need to synchronize "a"? Or do I actually have to synchronize on
each object I might access in another thread?
Thanks for the help!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JVM
Languages" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/jvm-languages?hl=en
-~----------~----~----~----~------~----~------~--~---