Alex Hurtt wrote:Assuming the application has no GUI, could the other answer be the main thread and the garbage collector? I would assume you'd have at least one garbage collector for each JVM process. (In other words, using Windows as an example, for each instance of the java.exe/javaw.exe process, one garbage collector).
Hmmmm I definitely would not be willing to repudiate your suggestion since I have spent a lot more of my time in the recent years working with C#. However, my intuition tells me that GC may be a part of the main thread. Garbage Collection isn't a process that is going on at all times. Objects are marked for GC but could take a long amount of time to actually be GCed (relative to processing speed). Therefore, I would not be inclined to suggest that GC would need it's own thread by default (that isn't to say that GC isn't executed on a asynchrnous thread started by the main thread). Many possibilities here.
I did a little reading on the Thread class in the Java 5.0 API
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). The Java Virtual Machine continues to execute threads until either of the following occurs:
This is interesting considering the question. However, it doesn't prove that there isn't a second thread of a daemon type.
Exerpt from Oracle's Threading Tutoria:
http://download.oracle.com/javase/tutorial/essential/concurrency/procthread.html
But from the application programmer's point of view, you start with just one thread, called the main thread. This thread has the ability to create additional threads, as we'll demonstrate in the next section.