-
Notifications
You must be signed in to change notification settings - Fork 62
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
Erase the chance of concurrent read/write. #82
Conversation
@@ -59,6 +59,7 @@ void testBytes() throws InterruptedException { | |||
getter.start(); | |||
countDownLatch.countDown(); | |||
adder.join(); | |||
getter.join(); |
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.
這個測試可以用ThreadPool
改寫嗎?
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.
使用ThreadPool
的話會讓這個測試產生"關聯",也就是說ThreadPool
的改動會影響到MetricsTest,想請問這樣是可以接受的嘛?還是用改使用ExecutorService
(是java的函式庫)?
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.
透過使用相同的APIs可以讓整個專案的程式碼風格更一致更好閱讀。
舉個例子,例如你這邊直接用thread、另一邊用Executor,這兩種寫出來的程式碼風格就會截然不同
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.
好的,瞭解。
countDownLatch.countDown(); | ||
adder.join(); | ||
|
||
ThreadPool threadPool = |
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.
please close the pool
}) | ||
.build(); | ||
threadPool.waitAll(); | ||
threadPool.close(); |
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.
please use try-with-resources
Solve the concurrent read/write in unit test.
Details describe in #76.