Is it possible to change the priority of garbage Collector thread?

后端 未结 4 994
花落未央
花落未央 2021-01-07 12:41

Java garbage collector runs with priority 1, due to which it is not guaranteed that System.gc() will actually execute if called.

Is there any way to change its prio

4条回答
  •  温柔的废话
    2021-01-07 13:32

    Even if you upped the thread priority to 11 System.gc will not guarantee anything. All you can be sure of is that if Java needs to GC it will before it throws an out of memory exception.

提交回复
热议问题