0

I have an application which has last statement System.out.println("Done");, it is written but after that the program is still running. How can I check why is it running?

Is it ok to use System.exit(0)?

The app is using only one (main) thread. Everything after Done is:

 System.out.println("Done.");

    } catch (ClassNotFoundException | SQLException e) {
        e.printStackTrace();
    }
}

}

Could it be database connection?

Ondrej Tokar
  • 4,898
  • 8
  • 53
  • 103

2 Answers2

1

Generate a thread-dump when you think the program has finished and look at the output to see where execution currently is. You may find it is not where you expect.

On Unix you should be able to do this using the kill -QUIT command (where pid is your process id). I believe on Windows you can use Ctrl + Break to do the same.

matt freake
  • 4,877
  • 4
  • 27
  • 56
0

We've just had a similar issue (albeit with a Ruby test system).

It turns out we'd run subprocesses which had become detached from the parent process, were hung waiting for something, but still held the stdout open, preventing our stream-monitoring loop from terminating, and holding the process alive.

I located the issue by running 'lsof' on the process that had apparently hung, seeing it had PIPEs still open, and tracking those down with more lsof.

android.weasel
  • 3,343
  • 1
  • 30
  • 41