Are you sure this is a thread safety issue? If you use java.net.Authenticator, it caches names / passwords if you do not:
AuthCacheValue.setAuthCache(new AuthCacheImpl());
AuthCacheValue and AuthCacheImpl - from sun.net.www.protocol.http. I do this in a class constructor that extends the authenticator
source share