After I start a SpringBoot web project. I can't find the main thread using jcmd $pid Thread.print
. I also can't find the main thread using hsdb
. Where did the main
thread go?
CodePudding user response:
I don't know the tool that you used in order to create your spring boot project, but if you created it via the Spring Initializr
(https://start.spring.io/) it should be on the path YOUR_PROJECT_NAME/src/main/java/YOUR_PERSONALIZED_PATH/
.
The name of the file where the main thread
is created/executed should be inside that path, and should be called YOUR_PROJECT_NAME Application.java
.
CodePudding user response:
For most Spring Boot apps, SpringApplication::run
involves starting a web server (Tomcat, Undertow, Jetty, Netty). Those servers create their own non-daemon threads. The call to SpringApplication::run
then returns and the main thread exits. The VM then is kept alive by those other non-daemon threads – the exact names depend on the web server used.
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}