I have been reading about Java multi threading. I came up across a topic on the resources share across threads here. It got me a bit confused about the local object references.
Local references to objects are a bit different. The reference itself is not shared. The object referenced however, is not stored in each threads's local stack. All objects are stored in the shared heap. If an object created locally never escapes the method it was created in, it is thread safe. In fact you can also pass it on to other methods and objects as long as none of these methods or objects make the passed object available to other threads.
The first couple of lines I can understand, however what does the author mean with the line in bold above ? More specifically, what does he mean by locally escaping ?
Could some one please care to explain, possibly with a different example.