In the book Java Concurrency in Practice , Brian Goetz says that objects passed to constructors and methods of a class are not owned by the Class itself . Is it because they are coming from outside and the class has no control over them ?
He goes on to say that there is an exception to this in cases where a method is explicitly designed to transfer ownership of objects passed in (such as Synchronized collection wrapper factory methods). Can some one give an example of the same and explain to me how this can be considered as an exception ?
An exception is
You can see that the way synchronizedList is designed it assumes ownership of thread safety responsibility so long as the wrapper object holds the only reachable reference to the underlying array list.