Should I wrap my curator (zookeeper library) calls within synchronized function in Java or will it be an overkill

StackOverflow https://stackoverflow.com/questions/23283481

Question

I am using curator library for zookeeper for interprocess lock across machines. There is just one function in which I create the lock, perform the work and then release the lock. Should I use synchronized keyword with this function to ensure that the threads on the same machine call this function serially and hence minimize calls to zookeeper or does it seem to be an overkill?

Était-ce utile?

La solution

Curator methods are all re-entrant and thread safe (unless specifically noted). So, no you don't need additional synchronization.

NOTE: I'm the main author of Curator.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top