I have singleton which holds connection to external service, this connection is declared as atomic reference
Connection connection = new AtomicReference<>(new Connection());
As long as this connection is used by my webservice, many threads may want to access this reference, so if one is using it at the moment, all others will wait.
I want to log information that thread is waiting for this reference, does anybody know how to detect that thread is waiting for atomic reference ?
Should I extend AtomicReference and wrap methods ? Is there any other way ?