Java thread method parsing: Sleep join wait notify Notifyall

Source: Internet
Author: User

Reprinted from:

Sleep (), yield (), wait () The difference is detailed: http://dylanxu.iteye.com/blog/1322066

The Join method is detailed: http://www.open-open.com/lib/view/open1371741636171.html

Description of difference:

Sleep (millsec) method: Causes the method's owning thread to pause millsec milliseconds, allowing other threads to be executed, but does not release the object lock .

Yield () method: Similar to the Sleep method, but cannot specify the time, and only the same priority thread has the opportunity to be executed.

Wait () method: Suspends the thread that the method belongs to and frees the object lock, while allowing the thread of the method to enter the " Waiting Pool " until a notify () or Notifyall () method is called, to be moved from the waiting pool to the lock flag waiting pool (only the lock flag waits for the thread in the pool to get the lock flag ).

Notify () Method: Remove a thread from the wait pool into the lock flag waiting pool .

Notifyall () Method: Move all the threads in the wait pool to the lock flag waiting pool .

Java thread method parsing: Sleep join wait notify Notifyall

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.