Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

引用范围不正确 #1

Open
dzyok opened this issue Feb 10, 2017 · 10 comments
Open

引用范围不正确 #1

dzyok opened this issue Feb 10, 2017 · 10 comments

Comments

@dzyok
Copy link

dzyok commented Feb 10, 2017

在\Jelly-master\jelly-service\src\main\java\service\service.java这个类56行开始

private void startTask(MessageHolder messageHolder) {
taskExecutor.execute(new Runnable() {
@OverRide
public void run() {
logger.info("开始执行取出的任务 messageHolder=" + messageHolder);
Dispatcher.dispatch(messageHolder);
}
});
}

messageHolder传参进来,不是final类型,在run方法中调用是会报错,不知道大神你运行过代码没有

@Yohann-Codes
Copy link
Owner

Yohann-Codes commented Feb 11, 2017

你用的JDK6吧,我用的JDK8,JDK8中已经没有匿名内部类和局部内部类只能访问final变量的限制了。

@Yohann-Codes
Copy link
Owner

代码当然运行过啊!

@dzyok
Copy link
Author

dzyok commented Feb 11, 2017

哦,原来如此,我还是用的JDK7呢,没有怎么用过JDK8,只知道JDK8大概的一些特性,涨势识了

@Yohann-Codes
Copy link
Owner

一起进步呦!

@dzyok
Copy link
Author

dzyok commented Feb 13, 2017

你碰到过这种情况没有,传输我是用的protobuf,就是通过自己来写处理业务的线程池,然后ctx.writeAndflush数据后,客户端只能接收到protobuf中的一部分参数值,需要的主要数据,始终传送不过来

@Yohann-Codes
Copy link
Owner

没有

@Yohann-Codes
Copy link
Owner

是不是编解码出错了

@dzyok
Copy link
Author

dzyok commented Feb 13, 2017

我知道是什么错了,如果只是handler那个线程里面,挨着执行writeAndFlush(),因为是protobuf,还需要执行数据的清除方法clearXXXXXX。我照着你的线程池来做,就不得行,clearXXXX方法需要在writeAndFlush方法返回Future,给future添加监听器完成事件,再调用clearXXXX。

@xiaoyaomimi
Copy link

请问为什么不使用protobuf,而选择使用json,你这么考虑的原因是什么,个人觉得protobuf更优秀一点

@Yohann-Codes
Copy link
Owner

Protobuf性能确实是好一些,但是不太会用。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants