ICE使用笔记---对线程池模式的浅析

因最近项目使用ICE,工作之余看了下,ICE处理线程方面的。

因为一个疑问,为什么客户端调用,会有个名为 Ice-ThreadPool.Client-0 的线程。既然客户端调用,使用的是客户端请求线程。

带着这个疑问,调试了下代码发现客户端发送请求,接收响应 是这样的

假如客户端线程C1 发送一个M消息,给服务端,那么发送以后,C1会挂起,java中表现为wait,Ice-ThreadPool.client-0线程收到响应数据,最后移交给C1,处理。同时,客户端线程池也可配置大小,等相关参数。

查看官网,发现下述信息:

Synchronous Method Invocation

By default, the request dispatch model used by Ice is a synchronous remote procedure call: an operation invocation behaves like a local procedure call, that is, the client thread is suspended for the duration of the call and resumes when the call completes (and all its results are available).


Introduction to Thread Pools

Each communicator creates two thread pools:

  • The client thread pool services outgoing connections, which primarily involves handling the replies to outgoing requests and includes notifying AMI callback objects. If a connection is used in bidirectional mode, the client thread pool also dispatches incoming callback requests.
  • The server thread pool services incoming connections. It dispatches incoming requests and, for bidirectional connections, processes replies to outgoing requests.

By default, these two thread pools are shared by all of the communicator's object adapters. If necessary, you can configure individual object adapters to use a private thread pool instead.

If a thread pool is exhausted because all threads are currently dispatching a request, additional incoming requests are transparently delayed until a request completes and relinquishes its thread; that thread is then used to dispatch the next pending request. Ice minimizes thread context switches in a thread pool by using a leader-follower implementation


这段说的是很是明白。ICE线程池的模式实现是leader-follower。包括客户端,服务端。


其次,在请求,处理不繁忙时,多余的线程会被销毁。客户端,服务端都剩余一个线程。

对于服务端出现 名为Ice-ThreadPool.Client-X的线程的解释:如果不使用  bidirectional mode 模式,基本没什么用。


由于没深入演习,理解难免有误。希望清楚的朋友,可以说下,谢谢。加入群,详谈,哈(群号:260013010)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值