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

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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top