Join Sleep yield

Source: Internet
Author: User

Join usage: Join is a non-static method

Thread Threada and THREADB, running simultaneously

1, if the Threada call their own join method, then Threada is blocked, even if the threadb end, Threada will not unblock. Threada jams Threada until Threada ends, deadlocks occur

2. If you call the Join (3000) method in Threada, the Threada is blocked by 3000ms and then run. Threada plug Threada 3000ms,

3, if the THREADB join method is called in Threada, the same Threada is blocked until threadb ends and Threada begins to run. THREADB Jam Threada until threadb ends

4, if in Threada call THREADB's Join (3000) method, Threada is also blocked 3000ms//threadb blocked Threada 3000ms

Sleep usage: Sleep is a static method

Block the current thread for a period of time so that other threads can continue to execute. However, it does not release the object lock, and if it is in the synchronized synchronization block, other threads still cannot access the shared data.

Use of Yield:

Yield usage is similar to sleep, except that it is not possible to specify the time of the blockage and only allow threads of the same priority to have the opportunity.

Join Sleep yield

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.