1. Threads and processes
(Recommended tutorial:java introductory tutorial)
(1) Process
A process is an independent unit of the system that allocates and calls resources. Each process has its own memory space and system resources;
(2) Thread
Thread: the execution unit of the process, execution path
Single thread: an application The program has only one execution path
Multi-threading: An application has multiple execution paths
What is the meaning of multi-process? ——Improve CPU usage
2. Parallelism and concurrency
Parallelism occurs physically at the same time, which means running multiple programs at the same time at a certain point in time;
Concurrency It occurs logically at the same time, which refers to running multiple programs at the same time within a certain period of time.
(Recommended video tutorial:java course)
3. Is the running principle of Java program and the startup of JVM multi-threaded?
The operating principle of Java program:
Start the JVM by the java command. JVM startup is equivalent to starting a process. Then the process creates a main thread to call the main method.
Is the startup of the JVM virtual machine single-threaded or multi-threaded?
The garbage collection thread must also be started first, otherwise memory overflow will easily occur.
JVM startup starts at least the garbage collection thread and the main thread, so it is multi-threaded.
The above is the detailed content of A brief overview of java multithreading. For more information, please follow other related articles on the PHP Chinese website!