This is the 13th day of my participation in Gwen Challenge

Brush the gold nine silver ten jump factory.

Processes and threads

1. The difference between a process and a thread

1. Processes are the smallest unit of resource allocation. Is a running program instance; Is a collection of resources that make up a running program. Each program running on the system is a process;

2. Thread is the smallest unit of CPU scheduling (with the operating system teaching materials); A set of instructions, or a special segment of a program, that can be executed independently within the program; You can also think of it as the context in which your code runs.

3. The relationship between the two: By default, a process contains only one thread (the main thread) and at least one thread, but a process can contain multiple threads. A thread is basically a lightweight process. A process is a collection of all threads, and each thread is an execution path in the process.

In addition:

1. A process can contain multiple threads

2. It is easy to share data among different threads in the same process, but difficult to share data among different processes

2. The memory address used by a thread can be locked. That is, when a thread uses some shared memory, other threads must wait for it to end before they can use the shared memory.

2. Communication between processes

Pipe: A half-duplex communication mode in which data flows only one way and can only be used between related processes. Process kinship usually refers to the parent-child process relationship.

Named pipe FIFO: A named pipe is also a half-duplex communication mode, but it allows communication between unrelated processes.

MessageQueue: a MessageQueue is a linked list of messages, stored in the kernel and identified by MessageQueue identifiers. The message queue overcomes the disadvantages of little signal transmission, pipe carrying only plain byte stream and limited buffer size.

SharedMemory: SharedMemory maps a segment of memory that can be accessed by other processes. This segment of SharedMemory is created by one process but can be accessed by multiple processes. Shared memory is the fastest IPC method and is specifically designed for the low efficiency of other interprocess communication methods. It is often used in conjunction with other communication mechanisms, such as semaphores, to achieve synchronization and communication between processes.

Semaphore: A Semaphore is a counter that can be used to control access to a shared resource by multiple processes. It is often used as a locking mechanism to prevent other processes from accessing a shared resource while one process is accessing it. Therefore, it is mainly used as a means of synchronization between processes and between different threads within the same process.

Socket: A Socket is also an interprocess communication mechanism. Unlike other communication mechanisms, it can be used to communicate between different processes.

Sinal: Signals are complex forms of communication used to inform the receiving process that an event has occurred.

3. Memory leaks

A memory leak means that the requested memory space is not released correctly, causing the memory to be permanently occupied (unreachable) in subsequent programs. When the pointer to the memory space no longer exists, the memory space will be permanently unreachable.

Second, Java foundation

1. Rewrite and reload

Overrides are subclasses that rewrite the implementation of the parent class’s accessible methods without changing either the return value or the parameter. Namely shell unchanged, core rewrite!

Overloading is when methods in a class have the same name but different parameters. The return types can be the same or different.

2. The way Java creates multithreading and multiprocessing

Multithreading in Java:

Thread class: Thread class: Thread class: Thread class: Thread class: Thread class

② Implement Runnable interface (this method is recommended, oriented interface programming):

Java provides two ways to start a process or other program:

(1) use the exec() method of Runtime

(2) Use the Start () method of the ProcessBuilder

3. Virtual machines

1. Heap and stack memory

Heap memory: storage arrays and objects (array is actually object), all new building is in the heap, the heap storage are entities (objects), the entity is used to encapsulate data, and it is encapsulated multiple multiple attributes (entity), if a data disappears, the entity did not disappear, you can also use, so the heap is not ready to release, But the stack is different, the stack is a single variable, the variable is released, then there is no more. Entities in the heap are not released, but are treated as garbage, and Java has a garbage collection mechanism that collects them from time to time.

Memory: stack memory is a memory area first, store are local variables, all defined in the method is a local variable is global variables of the (method), and local variable defined within a for loop, is to first load function to the definition of local variable, so the method advanced stack, and then to define variables, variables have their own scope, Once out of scope, the variable is released. Stack memory is updated quickly because local variables have a short lifetime.

Differences between the two:

1. Stack memory stores local variables while heap memory stores entities;

2. Stack memory is updated faster than heap memory because local variables have a short life cycle;

3. Variables stored in stack memory are released as soon as their life cycle ends, while entities stored in heap memory are collected irregularly by the garbage collection mechanism.

Iv. Database

1, internal connection and external connection

Inner join: Also known as equivalent join, returns the part of both tables that meets the condition

Inner join = join

The outer connection is divided into left outer, right outer and whole outer

The left outer join is to retain all data from the left table regardless of whether the condition in ON is full or not

Right outer join, that is, all data in the right table is retained regardless of whether the condition in ON is full or not

Mysql > select * from ‘on’; select * from ‘on’;