Why doesn't this thread pool get garbage collected?

前端 未结 6 567
长情又很酷
长情又很酷 2020-12-08 04:36

In this code example, the ExecutorService is used one and allowed to go out of scope.

public static void main(String[] args)
{
    ExecutorService executorSe         


        
6条回答
  •  -上瘾入骨i
    2020-12-08 05:10

    Finalizers are too unpredictable. Depending on them is usually bad practice. You can read more about it in "Effective java" by Joshua Bloch (item 1.7)

提交回复
热议问题