Explaining Synchronized, Serializing an Object, Transient and Volatile

Serializing an object

To serialize an object means to convert its state to a byte stream so way that the byte stream can be reverted back into a copy of the object.

  • When serializing an object, hashCode and toString method must be overriden
  • Instance variables marked as transient are not serialized.


If you mark an instance variable as transient, you're telling the JVM to skip (ignore) this variable when you attempt to serialize the object containing it.


The volatile modifier tells the JVM that a thread accessing the variable must always reconcile its own private copy of the variable with the master copy in memory.

Post new comment

The content of this field is kept private and will not be shown publicly.