It seems it hangs by an attempt to read cookie data from HTTPS response header. Not that easy to debug...
As a general recommendation limit the timeout for the network operations:
HashMap map = new HashMap();
map.put(PD4Constants.PD4ML_SOCKET_TIMEOUT , "60000"); // in ms
That should help to avoid the running out of threads. But it does not address the problem reason.
The best workaround would be to avoid HTTPS protocol by the local data exchange at all. A reference like <a src="/images/logo.png"> is more preferable than <a src="https://myserver/images/logo.png">
Please take into account, the link like <a src="https://myserver/images/logo.png"> can be built implicitly from <a src="/images/logo.png"> and <base href="https://myserver/">. In the case an overriding of the base with PD4ML API call parameters should help.
If the HTTPS is a must, you have to investigate the network issue reason... We need some more input