ctionManager与PoolingNHttpClientC

ctionManager与PoolingNHttpClientC

本文介绍了PoolingHttpClientConnectionManager与PoolingNHttpClientConnectionManager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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?

谢谢

推荐答案

PoolingHttpClientConnectionManager 维护 HttpClientConnection s,它提供同步/阻止通信.

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

PoolingNHttpClientConnectionManager 维护 NHttpClientConnection s,它提供异步/非阻塞和事件驱动的通信.

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

这两种类型都用 @Contract ,其中包含一个元素,用于指示在运行时强制执行的线程行为.

PoolingHttpClientConnectionManager 带有 @Contract(threading = SAFE_CONDITIONAL)注释,如果在构建时注入的依赖项是线程,则表明它是线程安全的-安全.

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 带有 @Contract(threading = SAFE)注释,因此可以认为它是完全线程安全的.

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

这篇关于PoolingHttpClientConnectionManager与PoolingNHttpClientConnectionManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 01:17