/*
* For Java programs, as long as there is a foreground thread, then the process is not finished
* If there is no foreground thread or all of it is a background thread, then the process ends
* Set a thread to be a background thread setdeamon (true); if a Setdeamon (false)
If False or by default (that is, not set), it means that the thread is a foreground thread
*
*
*
*/
Class Lesson5testdemo1
{
public static void Main (String [] agrs)
{
When our main thread ends, our process is not finished, because we still have a foreground thread that is still executing
New Lesson5testdemo2 (). Start ();
When we set up this thread as the background of the process, then the end of our main thread, then our process is over, because there is no foreground thread
Thread tt = new Lesson5testdemo2 ();
Tt.setdaemon (TRUE);
Tt.start ();
System.out.println ("Lesson5testdemo1:" + thread.currentthread (). GetName ());
}
}
Class Lesson5testdemo2 extends Thread
{
public void run ()
{
while (True)
& nbsp; {
system.out.println ("Lesson5testdemo2:" + thread.currentthread (). GetName ());
 &NBSP}
}