Package COM. partner4java; import Java. util. concurrent. timeunit;/*** when you set the background to run, and the thread does not report an error or perform Cleanup before the running ends, no more finally printed * @ author partner4java **/public class Test2 {public static void main (string [] ARGs) throws interruptedexception {// test1 (); // Test2 (); // test3 (); test4 ();} Private Static void test1 () throws interruptedexception {thread = new thread (New runnable () {@ overridepublic void run () {try {system. out. println ("try"); timeunit. milliseconds. sleep (1, 5000); thread. currentthread (). interrupt (); system. out. println ("Try last");} catch (exception e) {e. printstacktrace ();} finally {system. out. println ("finally") ;}}); thread. setdaemon (true); thread. start (); timeunit. milliseconds. sleep (1, 1000); system. out. println ("hello"); // background print: // try // Hello} Private Static void Test2 () throws interruptedexception {thread = new thread (New runnable () {@ overridepublic void run () {try {system. out. println ("try"); thread. currentthread (). interrupt (); system. out. println ("Try last");} catch (exception e) {e. printstacktrace ();} finally {system. out. println ("finally") ;}}); thread. setdaemon (true); thread. start (); timeunit. milliseconds. sleep (1, 1000); system. out. println ("hello"); // background print: // try last // finally // Hello} Private Static void test3 () {thread = new thread (New runnable () {@ overridepublic void run () {try {system. out. println ("try"); timeunit. milliseconds. sleep (1, 5000); system. out. println ("Try last");} catch (exception e) {e. printstacktrace ();} finally {system. out. println ("finally") ;}}); thread. setdaemon (true); thread. start (); thread. interrupt (); system. out. println ("hello"); // background printing: // Java. lang. interruptedexception: sleep interrupted //..... // Hello // try // finally} Private Static void test4 () {thread = new thread (New runnable () {@ overridepublic void run () {try {system. out. println ("try"); timeunit. milliseconds. sleep (1, 5000); system. out. println ("Try last");} catch (exception e) {e. printstacktrace ();} finally {system. out. println ("finally") ;}}); thread. setdaemon (true); thread. start (); int I = 1/0; system. out. println ("hello"); // background printing: // Java. lang. arithmeticexception:/by zero //... // try }}