Java: Why does this not get garbage collected?

前端 未结 4 1192
粉色の甜心
粉色の甜心 2021-01-03 18:39

Quick question about the theory of GCing. I have the following method. It runs, and exits the method. How come even after GC is run, the timer still exists and keeps \"TI

4条回答
  •  有刺的猬
    2021-01-03 19:20

    The timer's not being garbage collected because it's still running -- some other object (such as the thread scheduler) still has a reference to it, which was probably created inside scheduleAtFixedRate().

提交回复
热议问题