0

I have a class that i serialized objects of it. This class has states that might change by a process and serialized and saved in a file again.

The problem is that when multiple process deserialize a same file and change it's states and serialize it again, the consistency of this object (and the file that save serialized object) corrupted.

are there any mechanisms like locking , when a process deserialize an object from file, other processes can't access this file and can't deserialize it?

Alireza
  • 1
  • 2
  • Possible duplicate of [How can I lock a file using java (if possible)](https://stackoverflow.com/questions/128038/how-can-i-lock-a-file-using-java-if-possible) – Stanislav May 29 '17 at 07:58
  • 1
    That is not answer of my question. when you lock on FileInputStream it throws a NonWritableChannelException. Then in its answers said that to use RandomAccessFille class to read and write and how to use it for serialization?!!! – Alireza May 29 '17 at 08:16

0 Answers0