Several ways of communication between threads

Java inter-thread communication:

    1: Thread context

    2: Shared memory

    3: IPC communication

    4: Socket (Socket), communication between different machines

ALSO: P.S. Communications:

Communication methods between processes commonly used in linux
        (1), pipes: pipes can be used for communication between processes with affinities. It is a half-duplex method. Data can only flow in one direction, allowing one process to communicate with another. Communication between a process with which it has a common ancestor.
       (2) Named pipe: Named pipe overcomes the limitation that pipes have no name, and in addition to the function of pipes (also half-duplex), it also allows communication between unrelated processes. Named pipes have corresponding file names in the file system. Named pipes are created by the command mkfifo or the system call mkfifo.
       (3), signal (signal): signal is a relatively complex communication method, which is used to notify the receiving process that some event has occurred. In addition to inter-process communication, the process can also send signals to the process itself; in addition to supporting Unix early signals In addition to the semantic function sigal, it also supports the signal function sigaction whose semantics conform to the Posix.1 standard (in fact, this function is based on BSD. In order to achieve a reliable signal mechanism, BSD can unify the external interface and re-implement the signal function with the sigaction function) .
      (4), message queue: message queue is a linked list of messages, including Posix message queue system V message queue. Processes with sufficient permissions can add messages to the queue, and processes granted read permissions can read messages from the queue. The message queue overcomes the shortcomings of the small amount of information carried by the signal, the pipeline can only carry the unformatted byte stream and the buffer size is limited
      (5), shared memory: allows multiple processes to access the same memory space, which is the fastest available IPC form. It is designed for the inefficient operation of other communication mechanisms. It is often used in conjunction with other communication mechanisms, such as semaphores, to achieve synchronization and mutual exclusion between processes.
      (6) Memory mapping: Memory mapping allows communication between any number of processes, and each process using this mechanism implements it by mapping a shared file to its own process address space.
      (7), semaphore (semaphore): mainly as a means of synchronization between processes and between different threads of the same process.

     (8) Socket: A more general inter-process communication mechanism, which can be used for inter-process communication between different machines. Originally developed by the BSD fork of Unix systems, but is now generally portable to other Unix-like systems: Linux and System V variants both support sockets

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324588298&siteId=291194637