Mee Mee - 6 days ago 5
Java Question

Eclipse "Terminate/Disconnect All" behavior

As I was working in a Java project in eclipse, I right-clicked the Console region, and noticed that the Terminate/Disconnect All button was enabled. I was surprised by this, because the application I was working on was threaded. At first I thought this meant not all threads had terminated, but during design, I was meticulous in organization. Naturally, I went back and went through the code to see if anything would cause one of the threads to hang, but I didn't find much regarding this problem.

Afterwards, I wrote a small application to try to diagnose this problem, with more alarming results.

public class termtest {
public static void main(String[] args){
System.out.println("Did I terminate?");
}
}


Even this trivial program needs to be terminated via the "Terminate/Disconnect All" item.

Since I can't add images on mobile, here's a link to what I'm talking about: https://gyazo.com/7c87a1b01c1228a5ca4624008dceabd5

What explains this behavior on eclipse?

Answer

Your program has terminated as shown by the <terminated> message at the top of the console.

When your program terminates Eclipse does not destroy the JVM that was used to run the program immediately as this would clear the console log. Instead it keeps the JVM until you do one of

  1. Click the 'Remove Launch', or 'Remove All Terminated Launches' buttons
  2. Click the 'Remove All Terminated' context menu
  3. Run a new program.