A process is the basis of the operating system structure; it is an executing program; an instance of a program running in the computer; a process that can be assigned to a processor and executed by the processor Entity; a unit of activity represented by a single sequence of execution, a current state, and a set of associated system resources. (Recommended learning: java course)
First, a process is an entity. Each process has its own address space, which generally includes a text region, a data region, and a stack region. The text area stores the code executed by the processor; the data area stores variables and dynamically allocated memory used during process execution; and the stack area stores instructions and local variables for active procedure calls.
Second, a process is an "executing program". A program is an inanimate entity. Only when the processor gives life to the program can it become an active entity. We call it a process.
Characteristics of process
Dynamicity: The essence of a process is an execution process of a program in a multi-programming system. The process is dynamically generated and dies dynamically.
Concurrency: Any process can be executed concurrently with other processes
Independence: A process is a basic unit that can run independently, and it is also an independent unit for system allocation and scheduling of resources;
Asynchronicity: Due to the mutual constraints between processes, the process has intermittent execution, that is, the processes advance at independent and unpredictable speeds
Structural features: The process consists of programs, It consists of three parts: data and process control blocks.
Multiple different processes can contain the same program: a program constitutes different processes in different data sets and can obtain different results; but during execution, the program cannot change.
Creation of Java process
Java provides two methods to start a process or other program:
(1) Use Runtime’s exec( ) method
(2) Use the start() method of ProcessBuilder
ProcessBuilder
The ProcessBuilder class is newly added by J2SE 1.5 in java.lang A new class for creating operating system processes that provides a way to start and manage processes (that is, applications). Before J2SE 1.5, the Process class was used to implement process control and management.
Process
No matter which method is used to start the process, an instance of the Process class will be returned to represent the started process. This instance can be used to control the process and obtain relevant information. .
The above is the detailed content of What is a process in java. For more information, please follow other related articles on the PHP Chinese website!