PoolingHttpClientConnectionManager vs. PoolingNHttpClientConnectionManager

自古美人都是妖i 提交于 2021-01-28 05:06:15

问题


org.apache.http.impl.conn.PoolingHttpClientConnectionManager org.apache.http.impl.nio.conn.PoolingNHttpClientConnectionManager

What is the difference between these two types? Which one is more reliable in a multithreaded environment?

Thanks


回答1:


What is the difference between these two types?

PoolingHttpClientConnectionManager maintains a pool of HttpClientConnections, which provides synchronous/blocking communication.

PoolingNHttpClientConnectionManager maintains a pool of NHttpClientConnections, which provides asynchronous/non-blocking and event driven communication.

Which one is more reliable in a multithreaded environment?

Both types are annotated with @Contract which has an element to indicate the threading behavior enforced at runtime.

PoolingHttpClientConnectionManager is annotated with @Contract(threading=SAFE_CONDITIONAL) which indicates it's thread-safe if the dependencies injected at construction time are thread-safe.

PoolingNHttpClientConnectionManager is annotated with @Contract(threading=SAFE), so it can be considered fully thread-safe.



来源:https://stackoverflow.com/questions/46217135/poolinghttpclientconnectionmanager-vs-poolingnhttpclientconnectionmanager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!