I have a JFrame that shows the contents of the preview, since loading the preview data may take several times, and I decided to put the loading operation in SwingWorker, here is a sample code:
public void setPreviewContent(final String content) { SwingWorker<Void, Void> worker = new SwingWorker<Void, Void>() { @Override protected Void doInBackground() throws Exception { frame.setCursor(java.awt.Cursor.getPredefinedCursor( java.awt.Cursor.WAIT_CURSOR));
My frame is initialized every time it is displayed and positioned every time it closes:
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
After initializing and displaying the setPreviewContent() method, setPreviewContent() is called and works correctly, the only problem is that every time I close and open the preview frame again, a Daemon stream is created and it remains running:

As you can see shortly, a huge number of threads causing leakage remain operational. How can i solve the problem?
If I use standard Thread i, I don't have this problem ...
source share