[collection] can I avoid synchronized using a ReferenceMap ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[collection] can I avoid synchronized using a ReferenceMap ?

Nicolas De Loof-3


I'm building an UDP based integration service. Each 'client' sends a
query on UDP socket and waits for the response. A thread receives all
responses and dispatch to clients.

My current implementation uses an object that is used as message
When sending a message, the client adds its messageId object into a
shared map. After sending it's message, it does an 'messageId.wait()'.
The receive thread lookup the map for received id and calls notifyAll()
on the associated messageId Object. The client is unlocked and can
process response.

I'd like to avoid using a synchronized map, and I've read in
commons-collection javadoc about the ReferenceMap. Could it be used for
this ?
If I've understood how it works, I'm not required to remove my MessageId
objects from the map, and they will be removed when garbage collector
finalize my MessageId (after the UDP response has been processed).

Any suggestion is welcome.


This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient,  you are not authorized to read, print, retain, copy, disseminate,  distribute, or use this message or any part thereof. If you receive this  message in error, please notify the sender immediately and delete all  copies of this message.

To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]