What is the difference between serialization and synchronization in java? I need an explanation or a tutorial.
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.
More on serialization.
More on synchronization
Synchronization is a concurrency issue, e.g. how do you coordinate access to an object from multiple threads.
Here an arrow represents access.
s
[thread1] ---------------> y
n [shared object]
[thread2] ---------------> c
h
Serialization is the conversion of data structures and objects into a sequence of bits that you can store/transmit and then convert back to data structures and objects.
Here an arrow represents conversion.
deserialization
<---------------
[object] [binary]
--------------->
serialization
This is most useful when the deserialization happens at another place and/or time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With