• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we Serialize a HashMap object in a Thread  RSS feed

 
Jain Jose
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!