Do threads delete themselves?
Posted
by
Prog
on Programmers
See other posts from Programmers
or by Prog
Published on 2014-03-15T03:10:40Z
Indexed on
2014/08/23
4:27 UTC
Read the original article
Hit count: 212
Let's say I was working on a Swing application. Most of it is run on the EDT using SwingUtilities.invokeLater()
inside the main
method, because I heard (please correct me if I'm wrong) that that's what you need to do with Swing.
However, some parts of it shouldn't run on the EDT. These parts are parts that take long to complete (I assume that this is because long tasks on the EDT will interfere with GUI stuff the EDT should be doing, and thus these kinds of tasks should be run on parallel, on a different thread. Is this assumption correct?)
To do this, when I need to perform a task that takes long to complete and thus can't be run on the EDT like the rest of the program, I create a new thread and run that task inside it.
My question is: When the run()
method of that new thread finishes, aka the thread finished it's job. Does it delete itself? Or does it keep existing in the memory?
© Programmers or respective owner