Java Concurrency Threading Properties

Source: Internet
Author: User

Java Concurrency Threading Properties

@author Ixenos

Thread Priority

1. Whenever a thread scheduler chooses a new thread, first select a thread with a higher priority

2. By default, a thread inherits the priority of its parent thread

When you create another thread B in a running thread A, then a is the parent thread and B is the child thread.
When thread B is created in a running thread A, then thread C is created, while B is earlier than C, but B is not the parent of C, and a is the parent thread of B and C.

3. The priority of the thread is highly dependent on the system, and when the virtual machine relies on the thread implementation mechanism of the host platform, the priority of the Java thread is mapped to the host platform priority! The number of priorities may be more or less (Java has 10 priority levels)

4. If there are several high-priority threads that are not inactive, a low-priority thread may never execute! Because each time the scheduler decides to run a new thread, it first chooses in a thread with a high priority, which could starve the low-priority thread completely.

Daemon Threads

1. The only purpose of the daemon is to serve other threads (a timed thread is an example)

2. When only the daemon thread is left, the virtual machine exits

3. The daemon thread should never access the intrinsic resource (file, database) because it will break at any time

4. Call T.setdaemon (TRUE); To convert a thread to a daemon thread

Exception handler not caught

1. The thread's Run method cannot throw any detected exceptions, but exceptions that are not detected will cause the thread to terminate! But we don't need any catch clauses to handle exceptions, because before the thread dies, the exception is passed to a processor for an uncaught exception

2. (continued thinking in Java)

Java Concurrency Threading Properties

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.