Big Data-java Foundation -8day

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.