28 threads

Process: The task executed by the computer

Thread: implementation of the mandate of the small multi-threaded

The computer then perform the process, and then at the same time can only make the cpu core to execute a process. Constitute a process has multiple threads, then the same time Cpu can handle only one thread.

The introduction of multi-threading

  When a thread is executed cpu cpu to work, and thread needs to interact with software and hardware, this time cpu is idle

Reference multithreading can improve the efficiency of cpu

 

Create a multithreaded fashion ----- (Thead)

1. Thread class inheritance, override the run method (where the thread where the code logic, start method is called open thread. There is a bad place java is single inheritance can not inherit from other classes we inherited after Thread

, So we usually use the second method implements the interface

 

 

 

 2. implement Runnable, run method override (logical threaded code), by constructing Thread class object implement Runnable interface class object, calling the start method of the thread opening

 

Guess you like

Origin www.cnblogs.com/xuwangqi/p/11249416.html
28