If thread invalidates its cache after acquiring lock and flush its cache before release lock why is it necessary to make variable volatile in singleton pattern, since thread which aquires the lock later on should ideally invalidates its cache after acquiring lock and get the new value from the memory.
Moreover is this volatile keyword needed only for primitive type or objects which will be null initally, since objects which are already inirialized will be reference by memory adress in heap and value present will be updated always.