开发者

How to free up memory of an Executor Service that has been shut down for garbage collecting?

开发者 https://www.devze.com 2023-04-11 11:45 出处:网络
I am working on at the moment on a program that uses a lot of threads. A- My question is related to freeing up the executors once they have shut down for garbage collecting, what is the best way? I

I am working on at the moment on a program that uses a lot of threads.

A- My question is related to freeing up the executors once they have shut down for garbage collecting, what is the best way? I have read somewhere that I have to access the Future (Runnable or Callable) and affect it null for the garbage collector to pick it up.is that true?

B- Same question goes for thre开发者_开发技巧adpools?

Thanks for your help,


If there is no reference to the Executor Service anymore this should be done automatically.


Resources of inner Thread CallAble or Runnable are enabled to GC after it compleate, except resource which they return.

If you want force to run GC. You should call:

System.qc();

Then GC will start his work in background.

0

精彩评论

暂无评论...
验证码 换一张
取 消