Hi
I am trying to understand if I should synchronize the below factory method.I tested the code with three sample
thread and I am always getting the correct object for each thread(meaning Thread 1 always shows TYPE1,thread2 always show TYPE2 and thread3 always shows TYPE3 but I am still thinking that this may not be the case always unless I synchronize the factory method else it will not be thread safe meaning thread 1 could get type 2 or type 3 also.
Also another option is moving the static field b inside method so that it will be a local variable.
Please correct me If am wrong.
Thanks in advance.
Factory Class: