20165216 Eighth week learning tasks

2017-2018-2 "Java Programming" Week 8 Learning Summary

------------------------------------------------------------------------------------------------------

Summary of tutorial content

   1: Processes and threads

The concepts of both are related to the concept of programs.

Program: Static code, the blueprint for application software execution.

Process: a dynamic execution process of a program, which corresponds to the process of operating system loading from code --> execution --> execution and demise.

        (The operating system can manage 1 or more processes at the same time and execute them in turn)

Thread: A smaller unit of a process, and the dynamic progress of a process will generate multiple threads. Threads also have a dynamic slave

The process of birth to death. Both belong to an inclusive relationship.

 2: Main thread

A thread started after the main method is found, responsible for executing the main method, called "main thread".

(1 && 2)

① Four states of the thread

   New --> Run --> Interrupt --> Die

(Because the processes are switched in turn, they can all occupy the CPU, which will also cause thread interruptions.)

② Common methods of thread

1: start()  2:run() 3: sleep(int millsecond) 4:isAlive() 5:currentThread() 6:interrupt

3: Thread class

 ① The construction method of using Thread to create a thread: Thread(Runnable target)

     (The parameter is the interface of the Runnable type, for the actual example, please refer to Example12_3.java)

 

 

code hosting

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324687803&siteId=291194637