Forums Register Login

Can we Serialize a HashMap object in a Thread

+Pie Number of slices to send: Send
Hi All

I am trying to serialize a HashMap object in to a file and then deserialize it. I want to use thread for both the purpose. When I tried, it serialized the object but while trying to deserialize the object, it is giving the following error

java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(Unknown Sourc

e)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at DeSerThread.run(DeSerThread.java:15)
at java.lang.Thread.run(Unknown Source)

To Serialize and Deserialize I am calling the following threads(My own test code). I am using

Threads are



cde.tmp is created in the appropriate folder. Can any one help it. Thanks in advance
+Pie Number of slices to send: Send

It may be a good idea to let the serialization thread finish, before starting the deserialization thread. At minimum, you should let the serialization thread close the file, before the deserialization thread opens it.

Henry
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 2000 times.
Similar Threads
Inner class & serialize
Question on serialization !
encapsulation breaked ? ?
Problem with serializing a class
Getting error while serializing. Please see the following code while produces IOException.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:55:31.