13

I have created a sample java application working with Hibernate, when I doing the thread-dump I observe the strange thread called Java2D Disposer.

Can someone tell me the function of that thread?

Marco
  • 131
  • 1
  • 4

1 Answers1

15

Certain entities in the AWT system need finalization to free resources. The most prominent example is java.awt.Windows which needs to dispose its native resources after the window is garbage collected.

One could do this with finalizers, but a solution that gives you more detailed control is to use phantom references with a reference queue. That solution needs a dedicated thread which waits on the reference queue. That thread is the "Java 2D disposer" thread, It is created when you initialize the AWT system.

Ingo Kegel
  • 46,523
  • 10
  • 71
  • 102
  • 1
    Clean answer! Could you explain me what are those native resources and why should they be disposed? – JavaTechnical Feb 05 '14 at 18:57
  • we saw this thread in our thread dumps of our web service which does NO UI work at all. is there a way to stop creating this thread? or should we not worry about this at all? – asgs Aug 18 '23 at 16:41