提交 8ea3c969 编写于 作者: oldratlee's avatar oldratlee 🔥

improve test stability

上级 e8919c2c
......@@ -87,10 +87,13 @@ private fun checkThreadPoolExecutorForRemoveMethod(executor: ThreadPoolExecutor)
assertFalse(taskToRemove.isDone)
assertFalse(taskToRemove.isCancelled) // task is directly removed from work queue, so not cancelled!
println("executor.activeCount: ${executor.activeCount}")
Thread.sleep(1)
println("executor.activeCount: ${executor.activeCount}") // NOTE: activeCount value is not strong published
Thread.sleep(1) // read and wait, then assert check!
assertEquals(0L, executor.activeCount.toLong()) // No more task in executor, so remove op is success!
assertFalse(taskToRemove.isDone)
assertFalse(taskToRemove.isCancelled) // task is directly removed from work queue, so not cancelled!
}
private fun checkScheduledExecutorService(scheduledExecutorService: ScheduledExecutorService) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册