JAVA thread Basics

Source: Internet
Author: User

 
A thread is a part of the Java language and one of the most powerful functions of Java. What is thread? Why do we need to develop thread-based applications? In this article, we will have a deep understanding of the usage of threads and some techniques for using threads. Before we start to talk about the thread, we 'd better first understand the background knowledge and analyze the working principle of the thread.
When programmers start developing applications, these applications can only accomplish one thing in one time. Applications are executed from the main program until the execution ends, as is true for languages such as Fortran, Cobol, and Basic.

With the passage of time, the computer has evolved to the era when more than one application program can be run in the same period of time, but the application program is still serial, that is, from the start to the end, the next instruction is followed by the previous instruction. Recently, the program has been developed to run in the form of several threads during execution. Java has the ability to run multiple threads and can perform several operations within the same time period. This means that a given operation does not have to wait until another operation is completed. You can specify a higher priority for an operation.

Many programming languages, including ADA, Modula-2 and C/C ++, can already provide support for threads. Compared with these languages, Java supports threads from the very bottom. In addition, the standard Java class is reentrant, allowing multiple threads in a given application to call the same method, tb, and threads do not interfere with each other. These features of Java lay the foundation for the design of multi-threaded applications.

What is a thread?

What is thread? As shown in Figure A, A thread is A sequence of given commands (your code), A stack (variables defined in the given method ), and some shared data (Class-level variables ). The thread can also access static data from the global class.

# G_kclist {font-size: 12px; width: 570px; float: none; margin-top: 5px; clear: right} # g_kclist a {color: #000; text-decoration: none} # g_kclist h2 {margin: 0px; padding: 0px; font-size: 14px; text-align: center; background: url (http://www.thea.cn/zt/zt_img/zczhongduan.gif) no-repeat; line-height: 31px; color: # fff} # g_kclist table {line-height: 25px; background: # B0DA90; margin-top: 8px} # g_kclist table td {text-align: center; background: # fff} # g_kclist table td. td1 a {color: # f00} # g_kclist table th {background: # F2F7ED; color: #525F46}

With the help of others, I will go further.

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.