Jake
Jake

Reputation: 15217

How to serialize an object of type Object?

I have a class that contains an object of type Object (which is used as a monitor for synchronization). Since Objects are not Serializable, what can I substitute to make serialization work?

Upvotes: 2

Views: 330

Answers (2)

santiagobasulto
santiagobasulto

Reputation: 11686

A monitor for synchronization? Have you tried with ReentrantLock Like Jonathon said. You should mark it as transient

Upvotes: 0

Jonathon Faust
Jonathon Faust

Reputation: 12545

I wouldn't think a field used for synchronization would need to be serialized.

Mark it transient.

Upvotes: 10

Related Questions