Java multithreading (1)-method join

Source: Internet
Author: User

For Java developers, multithreading should be a knowledge point that must be skilled in application, especially for developing Java-based products. This article will give an in-depth explanation of the knowledge points of Java multithreading. In the subsequent series, it will focus on the design idea, implementation and application of concurrent parallel packages provided by Professor Doug Lea in Java 5.
How can we get it deeper? My understanding is that there is a problem, not a general view. Therefore, this series mainly focuses on solving problems. Of course, I also hope that readers can come up with better solutions and more questions. Due to the limited level, if there are any errors, please raise them and discuss them together. In short, I hope that through this series we will have a deep understanding of Java multithreading to solve our actual development problems.
As a developer, I don't think it is necessary to discuss the basic knowledge of multithreading, such as what is a thread? How to create and so on, these knowledge points can be obtained through books and Google. This series focuses on how to deeply understand multithreading to help our normal development, such as how to implement the thread pool? How to Apply locks.

(1) What is the use of join? Simple answer: How to synchronize synchronization? How to implement it? The answer is as follows.
Since I started to use Java multithreading, I have never understood join. JDK says this:
Join
Public final voidJoin(Long millis) throws
Interruptedexception
Waits at mostMillisMilliseconds for this thread to die. A timeout
0Means to wait forever.
Do you understand this? It literally means waiting for a while until this thread dies. My question is whether the thread is its own thread or the thread that calls it. The code above:

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.