Talking about multi-threaded

At the beginning of multi-threading learning, we must first understand a few important concepts

First, the threads and processes

Process: operating system resource allocation and scheduling of independent units

Thread: is the process of independent sub-tasks running

A process can contain multiple threads

 

Second, random

Even starting the thread code has order, and actually start calling thread is random, cpu time slice has been switched

 

Third, thread-safe and non-thread-safe

In a multi-threaded, the use of other techniques to ensure the locking of shared data is not dirty read, tampering is thread safe, whereas non thread-safe

 

Fourth, the guardian of the threads and user threads

There are two threads: Daemon threads and user threads

Daemon thread feature: When the last user thread, daemon thread will end along with the JVM, GC is the most typical daemon thread

 

Fifth, atomicity

Either do an action, then do not do (do not exist only in half of cases)

 

 

Guess you like

Origin www.cnblogs.com/g1191613819/p/11987949.html