Java Reference
In-Depth Information
y d
Figure 6-5. Shared memory between threads
This leads to a general design principle of Java—that objects are visible by default . If
I have a reference to an object, I can copy it and hand it off to another thread with
no restrictions. A Java reference is essentially a typed pointer to a location in mem‐
ory—and threads share the same address space, so visible by default is a natural
In addition to visible by default, Java has another property that is important to fully
understand concurrency, which is that objects are mutable —the contents of an
object instance's fields can usually be changed. We can make individual variables or
references constant, by using the final keyword, but this does not apply to the con‐
tents of the object.
Search WWH ::

Custom Search