Difference Between Serializable in thread and Synchronized

Ans.1.Synchronization refers to multi-threading. A synchronized block of code can only be executed by one thread at a time.

Serialization refers to converting objects to bitstreams either for storage or transmission. The act of serialization encodes the data according to specific rules. This bitstream can then be deserialized later or on a remote system that receives it. For serialization to work the class definition must match (i.e. you need to be using the same version of the class or one that is guaranteed to be compatible) and the class must implement the Serializable interface.

2.Serialization is a mechanism in Java for flattening objects out to disk or a stream and then reassembling them on the other end or when they are re-instantiated.

Synchronization is a concurrency mechanism in Java to restrict blocks of shared data/code from being accessed by more than one thread at a time.

People who read this post also read :



2 comments:

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More