|
|
|
| Some threads are intended to be "background" threads, providing services to other threads. These threads are called daemon threads. UNIX has a similar concept for processes, where certain operating system services are provided by daemon processes. (For some reason, it has become traditional to use the archaic spelling for demon.) Microsoft Windows uses Windows services for similar operations. When a Java thread is created, it is a non-daemon thread. It may be changed (or change itself) to a daemon thread by calling its setDaemon() method. (There is also a matching isDaemon() method.) When a Java Virtual Machine starts up, there is usually a single non-daemon thread (which typically calls the method named main of some designated class), and one daemon thread -- the garbage collection thread. The Java Virtual Machine continues to execute threads until either of the following occurs:
or:
|
| The page was last updated February 19, 2008 |