-
Notifications
You must be signed in to change notification settings - Fork 93
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
Request for JDK and Spring ThreadPool implementation #64
Conversation
…ools into feat/thread.pool
core/src/main/java/com/alipay/sofa/common/thread/SofaThreadPoolExecutor.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/alipay/sofa/common/thread/SofaThreadPoolExecutor.java
Show resolved
Hide resolved
@Override | ||
protected void beforeExecute(Thread t, Runnable r) { | ||
super.beforeExecute(t, r); | ||
executingTasks.put(r, new RunnableExecutionInfo(t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里的 r 是一个 Runnable 的接口,put 和 remove 应该是根据 equals 来进行对比吧,如果有个使用者定制了 equals 方法导致两个 Runnable 是相等的,那是否会造成这里的计算不准确?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
map 对于 key 相同的判断需要同时 override equals 和 hashcode 两个方法,如果用户的确同时覆盖了这两个方法,那的确是用户的语义就是想要这两个 runnable 相等,我们这里保持一致应该没有问题吧?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
对与 put 覆盖了的情况,第二个 remove 操作不会报错,只是第二个 runnable 会在第一个 runnable 结束之后 remove
fix: #62