NettyRPC icon indicating copy to clipboard operation
NettyRPC copied to clipboard

客户端并发调用,dump看了一下大量线程阻塞在一个地方

Open yeyincai opened this issue 8 years ago • 2 comments

MessageCallBack类

public Object start() throws InterruptedException {
        try {
            lock.lock();
            finish.await(10 * 1000, TimeUnit.MILLISECONDS);
            if (this.response != null) {
                return this.response.getResult();
            } else {
                return null;
            }
        } finally {
            lock.unlock();
        }
 }

不明白这句代码何意 finish.await(10 * 1000, TimeUnit.MILLISECONDS); 一定要嘛?

yeyincai avatar Dec 29 '16 12:12 yeyincai

这个是用来等待服务端发送过来的RPC调用执行结果消息用的。

tang-jie avatar Mar 24 '17 01:03 tang-jie

当单线程循环调试某个方式时,出现bug,这样改是否更合理?

lock.lock();
if(this.response==null){
    //限定时间内未被唤醒则抛出异常
    if(!finish.await(RpcSystemConfig.SYSTEM_PROPERTY_MESSAGE_CALLBACK_TIMEOUT, TimeUnit.MILLISECONDS)){
        throw new InvokeTimeoutException(RpcSystemConfig.TIMEOUT_RESPONSE_MSG);
    }
}
if (this.response != null) {

sky4160864 avatar Dec 19 '18 05:12 sky4160864