Process
-----------------------------------------
1. Processes are isolated in memory (memory is not shared).
2. Communication between processes is through the socket, which is also required on the same computer.
Thread
--------------------------------------
1. Code blocks that execute concurrently during the execution of the program.
2. Share memory between threads.
3. A process must have at least one thread (the main path).
4.Thread: Thread class.
Start (); Notifies the CPU that the thread can start executing.
Run (); The code block that the thread specifically executes. The method has no return value and no parameters.
Thread t = new thread (); Creates a thread.
T.start (); Run.
5.thread.currentthread (); Gets the currently executing thread.
6.yield (); Discard CPU preemption Rights
7.sleep (int mils); Lets the current thread hibernate for the specified number of milliseconds.
8.join (); Waits for the specified thread to end
9.thread.setdaemon (TRUE); The daemon thread. Must be set before thread start.
10.synchronozed (lock) {...} Synchronize code blocks.
Producers and consumers
-----------------------------------------------
Notify: Randomly notifies a thread in the waiting queue.
Notifyall: Notifies all threads in the waiting queue.
Big Data-java Foundation -8day