Here is a typical SpringApplication instance:
public class MyService {
public static void main(String[] args) throws Exception {
SpringApplication app = new SpringApplication(MyService.class);
ApplicationContext ctx = app.run(args);
}
}
Since app.run(args) is a non-blocking call, the main method of this application returns immediately after its invocation. I have always thought that an application terminates when you return from main.
Why does SpringApplication continue run even though we have returned out of main?
The JVM terminates when the last non-daemon thread finishes. It seems that your application is creating thread(s) that do not terminate.
On Unix, you can find out what is the state of your threads by sending signal 3 (kill -3 <java-pid>) to get a thread dump on output. That could tell you more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With