In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to analyze Java basic multithreading, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain for you in detail, people with this need can come to learn, I hope you can gain something.
Multithreading is a very important aspect of Java learning and a basic skill that every Java programmer must master.
I. process
A process is the basis of the structure of the operating system; it is the execution of a program; it is the activity that occurs when a program and its data are executed sequentially on the processor. In the operating system, almost all running tasks correspond to one process (Process). When a program runs into memory, it becomes a process. A process is a program that is running and has certain independent functions. There is a classic saying that describes a process-- a process is an independent unit of the system for resource allocation and scheduling.
A process is an independent entity in the system, with its own independent resources and its own private address space. The essence of a process is an execution process of a program in a multiprogramming system, which is dynamically generated and dies out, and has its own life cycle and different states. A process has concurrency, which can be executed concurrently with other processes and move forward at an independent and unpredictable speed.
(note that concurrency and parallel are different. Parallelism means that multiple instructions are running on multiple processors at the same time. Concurrency means that only one instruction can be executed at a time, but multiple process instructions are rotated quickly, as if multiple instructions were executed at the same time. )
The process consists of three parts: program, data and process control block.
II. Thread
A thread, sometimes called a lightweight process (LightweightProcess,LWP), is the smallest unit of a program's execution flow. A standard thread consists of thread ID, current instruction pointer (PC), register set, and stack. In addition, a thread is an entity in a process and a basic unit that is independently dispatched and dispatched by the system. The thread itself does not own system resources, but has only a little bit of essential resources in running. However, it can share all the resources owned by the process with other threads belonging to the same process. One thread can create and undo another thread, and multiple threads in the same process can execute concurrently. Due to the mutual restriction between threads, threads are intermittent in operation. Every program has at least one thread, and if the program has only one thread, it is the program itself.
A thread is a single sequential control flow in a program. Running multiple threads at the same time to accomplish different tasks in a single program is called multithreading.
In Java Web, it should be noted that threads are at the JVM level and die together with JVM without stopping, that is, if a Web service starts multiple Web applications and a Web application starts a thread, if the Web application is closed, the thread will not be closed, because the JVM is still running, so don't forget to set the Web application to stop when it shuts down.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.