You can learn more about the problems with the original Java memory model, and the changes that were made for JDK 5, at
Bill Pugh's Java Memory Model page. For your question on volatile, a good place to start might be
What does volatile do?.
[Santhosh]: When a thread writes a value to a volatile variable, does it synchronize all the latest values of its member variables to the main memory ? It's misleading to say "synchronize" here, since in Java, "synchronize" has a specific meaning. Volatile has
some of the effects of synchronization, but not all of them. Volatile is
like synchronization in terms of its effect on the memory model, but it's
unlike synchronization in the sense that volatile will never block threads from concurrently accessing a particular method or block of code. Your question is apparently about the former effect only.
In answer to your question, I would say that the JVM will write and read to and from main memory, as necessary, in order to ensure that any data that was visible to thread A
before it wrote to a volatile variable, will also be visible to thread B
after it reads from the same volatile variable.
It's up to the JVM whether this means it writes/reads
all data from a given object to/from main memory, or just some of it. Or none of it. It's possible that the JVM may determine that only one other field is being read after a volatile access, and therefore it's possible to refresh just that one field, leaving the other fields alone. It's hard for us to say. Basically, you can assume that your program will behave
as if all the fields have been refreshed. If the JVM finds it's able to avoid some of that work without changing the behavior of the program (other than to make it faster), it may do so. It's often hard for us to know exactly what's
really going on inside the JVM, because there are many optimizations that it performs.