From 9dbef5d9b064e1c6acccdda3f76ad1369802737c Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 4 Feb 2016 14:15:49 +0000 Subject: [PATCH] Remove use a separate runner thread from the Launcher Previously, the Launcher was creating a new runner thread that would call the application's main method. An exception thrown by this thread is handled differently to one thrown by the JVM's main thread leading to different exit behaviour. Furthermore, the separate thread isn't actually necessary. This commit removew the use of a separate runner thread from the Launcher. This means that the JVM's exit behaviour will be consistent and also removes the overhead of createing a starting an extra thread. Closes gh-5006 --- .../main/java/org/springframework/boot/loader/Launcher.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java index 0cc46da993..887f28e682 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java @@ -97,10 +97,8 @@ public abstract class Launcher { protected void launch(String[] args, String mainClass, ClassLoader classLoader) throws Exception { Runnable runner = createMainMethodRunner(mainClass, args, classLoader); - Thread runnerThread = new Thread(runner); - runnerThread.setContextClassLoader(classLoader); - runnerThread.setName(Thread.currentThread().getName()); - runnerThread.start(); + Thread.currentThread().setContextClassLoader(classLoader); + runner.run(); } /**