The program is a long live process with start time and end time. I executes the program using java -verbose:gc [Java class]. Once the program reaches end time, the program will go to the end. However, it looks like it doesn't go to the end because I still can see the GC message keeps coming out, i.e. [GC 892K->339K(5056K), 0.0023834 secs].
Java application process doesn't end when main method is completed. It ends when all threads are completed. I don't know what are you doing in your while loop but if new Threads were started there this could be the reason.
Joined: Apr 10, 2003
Thanks for your valuable information, Viktor.
Let me give more information. What the loop does is
1. Use Runtime.exec to execute another java process
2. At the same time it creates two threads to monitor the above process Error Stream and Input Stream. The thread looks like the following :