A: Knowledge Point statement:
1. Differentiate processes and threads: a process is a static concept, and its execution depends on the thread.
2. Status of the process: Ready (Waiting for CPU execution), run, Abort, block (wait for required resources, enter blocking state)
The main function of the 3.Java program is a thread, which is called the main path. If you create a new thread at this point, it runs in parallel with the main threads.
The constructor method in 4.Java, the main function who executes first?
The main function executes first because main is a static method, and the program executes at the beginning, and the constructor is called only when the class is instantiated.
Two: Instance program
public class GetCurrentThread implements Runnable {Thread th;public getcurrentthread (String threadname) {th = new Thread (t His,threadname); <----DOUBTSystem.out.println ("Get ThreadName" +th.getname ()); Th.start ();} public void Run () {System.out.println (Th.getname () + "is starting ..."); System.out.println ("Current thread Name:" + Thread.CurrentThread (). GetName ());} public static void Main (String args[]) {System.out.println ("Current thread Name:" + Thread.CurrentThread (). GetName ()); n EW getcurrentthread ("1st thread");//new getcurrentthread ("2nd thread");}}
III: Implementation Results
Four: Procedure analysis process (directly with notes)