I think the short answer is that you need to use synchronization and take a performance hit.
Given that JMX calls are RMI / network based, a block synchronizedwould be very cheap in comparison. Any solution that you implement that has a usage counter will suffer from race conditions, especially considering that the JMXConnector most likely does not have protection against closing / joining conditions. For example, someone may close the connection at the same time that someone is connecting, and the new connection may be closed.
I think you should write a wrapper class (or method) for the connector. It would be:
- ,
connect() ( 0), getMBeanServerConnection() . - close, , 0.
- , .
.