提交给 ScheduledExecutorService 的任务在 "waiting" 到 运行 期间做了什么
What do tasks submitted to ScheduledExecutorService do while "waiting" to run
如果我有这样的东西
scheduledExecutorService.schedule(task,60, TimeUnit.SECONDS);
在 60 秒未到时 "task" 会发生什么。会不会消耗资源?因此,下一个问题和我的具体用例是,如果我有很多 "tasks" 需要安排,那么 memory/resource 是否有效?我的任务是短暂的,但我担心将数百个任务安排到 scheduledExecutorService 的影响。
What happens to "task" while that 60 seconds is not up yet. Does it consume resources?
它在 PriorityQueue 中等待,所以是的,它使用了一些资源。
Consequently, the next question and my specific use case is what if i have a lot of "tasks" to schedule, would that be memory/resource efficient?
并不比将它们存储在队列中差多少。
My tasks are short-lived but i'm concerned about the implications of scheduling hundreds of tasks to the scheduledExecutorService.
假设每个任务使用 1 KB,您将浪费 100 KB。不太可能成为问题。
假设每个任务使用 1 GB,那么您可能会遇到问题。我建议你换一种方式。
如果我有这样的东西
scheduledExecutorService.schedule(task,60, TimeUnit.SECONDS);
在 60 秒未到时 "task" 会发生什么。会不会消耗资源?因此,下一个问题和我的具体用例是,如果我有很多 "tasks" 需要安排,那么 memory/resource 是否有效?我的任务是短暂的,但我担心将数百个任务安排到 scheduledExecutorService 的影响。
What happens to "task" while that 60 seconds is not up yet. Does it consume resources?
它在 PriorityQueue 中等待,所以是的,它使用了一些资源。
Consequently, the next question and my specific use case is what if i have a lot of "tasks" to schedule, would that be memory/resource efficient?
并不比将它们存储在队列中差多少。
My tasks are short-lived but i'm concerned about the implications of scheduling hundreds of tasks to the scheduledExecutorService.
假设每个任务使用 1 KB,您将浪费 100 KB。不太可能成为问题。
假设每个任务使用 1 GB,那么您可能会遇到问题。我建议你换一种方式。