For things like this I use the following ObjectHolder.
For things like this I use the following ObjectHolder: public class ObjectHolder { private T m_object; public ObjectHolder( T object ) { m_object = object; } public T getValue() { return m_object; } public void setValue( T object ) { m_object = object; } } Then you can use final ObjectHolder productHolder = new ObjectHolder( new Product() ); ...and inside your anonymous class you can access your Product with productHolder.getValue(); ...or change it's instance with productHolder. SetValue( new Product() ).
Declare it final. Anonymous inner classes have access to final local variables: public void someMethod() { ... final Product product = new Product(); ... transactionTemplate. Execute( new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult (TransactionStatus status) { doSomething(product); return; }}); ... }.
I can't, product is an instance type and it needs to be loaded in the containing method and I don't want to make this a class member variable either. The containing method will be called repeatedly so I don't think making it static would work unless i'm missing something. – James Jan 21 '10 at 19:52 @James: I mean a final local variable – axtavt Jan 21 '10 at 19:53 This method will be called by different threads it's being used in a web application.
If I make the local variable final that would not be thread safe would it? – James Jan 21 '10 at 19:56 The final keyword on a variable marks that the variable is a constant. It's not like a static in C++ – axtavt Jan 21 '10 at 20:06 James - think of it this way.
SomeMethod executes in thread one and defines product product and freezes. SomeMethod executes in thread two and defines product product, but it has its own product - it didn't overwrite product in thread one because thread one's product exists only in the execution of thread one. When thread two gives up, and thread one resumes, the product of thread one is still there - it's instance variables you must be careful with when executing methods that could be used by two threads at the same time.
– MetroidFan2002 Jan 21 '10 at 21:34.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.