ThreadFactory usage in Java

前端 未结 10 1907
旧巷少年郎
旧巷少年郎 2020-12-02 05:08

Can someone briefly explain on HOW and WHEN to use a ThreadFactory? An example with and without using ThreadFactory might be really helpful to understand the differences.

10条回答
  •  日久生厌
    2020-12-02 05:30

    IMHO the single most important function of a ThreadFactory is naming threads something useful. Having threads in a stacktrace named pool-1-thread-2 or worse Thread-12 is a complete pain when diagnosing problems.

    Of course, having a ThreadGroup, daemon status and priority are all useful too.

提交回复
热议问题