Java: Multi-threaded < four > Lock, stop thread, daemon thread, join, priority &yield

Source: Internet
Author: User

After Java1.5, condition decomposes the object monitor method (Wait, notify, notifyall) into distinct objects so that they can be combined with any lock implementation to provide multiple wait sets (Wait-set) for each pair of images. Period, lock replaces the use of synchronized methods and statements, condition replaces the OBJETC monitor method and uses.

When the thread is in a frozen state, it is possible that the thread will not end, and interrupt is used to clear the frozen state of the thread. This is required to purge the frozen state when there is no specified way to get the frozen state of the thread back to the running state. Forces the thread to revert to the running state. This makes it possible to manipulate the tag to end the thread.

Daemon Thread:

Setdaemon (True) is used to turn a thread into a daemon (user thread, background thread) when the running thread is a daemon thread, and the Java Virtual machine is launched.

The method must be called before the thread is started.

Join:

Join () robs the CPU of executive power. Wait for the thread to end.

Priority level:

The frequency of the grab CPU resources, the thread default level is 5, the thread level range is 1-10.

setpriority (int newpriority) sets the thread level. Parentheses can also be written in thread.max_priority, thread.min_priority ...

Yield

Pause Current thread

——————————————————————————

The content of this section, later in-depth re-fill the

Java: Multi-threaded < four > Lock, stop thread, daemon thread, join, priority &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.