Unlike most other computer languages, Java has built-in support for multithreaded programming (multithreaded programming).
Multi-threaded programs contain two or two more concurrently running portions. Each of these parts of the program is called a thread, and each thread has a separate execution path. Therefore, multithreading is a special form of multitasking.
You must know multitasking because it is actually supported by all modern operating systems. However, there are two distinct types of multitasking: process-based and thread-based. It is very important to know the difference between the two.
For many readers, process-based multitasking is a more familiar form. A process is essentially a program that executes. Therefore, process-based (process-based) multitasking is characterized by allowing your computer to run two or more programs at the same time. For example, process-based multitasking allows you to run a Java compiler at the same time as you use a text editor. In a process-based multitasking process, the program is the smallest unit of code that the dispatcher dispatches.
In a thread-based-based multitasking environment, a thread is the smallest execution unit. This means that a program can perform functions of two or more tasks at the same time. For example, a text editor can format text at the same time as it is printed. So, multi-process programs deal with "big picture", while multi-thread program handles detail problems.
multithreaded programs require less administrative overhead than multi-process programs. Processes are heavyweight tasks that need to allocate their own separate address space. Inter-process communication is expensive and limited. The transition between processes is also very expensive. threads, on the other hand, are lightweight players. They share the same address space and share the same process together. Inter-thread communication is inexpensive, and switching between threads is also low-cost. When a Java program uses a multi-process task processing environment, the multi-process program is not controlled by Java, while multi-threading is controlled by Java.
Multithreading helps you write efficient programs that maximize CPU utilization, because idle time is kept to a minimum. This is critical for the interactive network-connected environment that Java runs on, because idle time is public. For example, the network data transfer rate is much lower than the computer processing power, the local file system resources read and write speed is much lower than the CPU processing power, of course, user input is also much slower than the computer. In a traditional single-threaded environment, your program must wait for each of these tasks to complete before performing the next step-even though the CPU has a lot of idle time. Multithreading allows you to get and take advantage of these idle times.
If you have programming experience under an operating system such as Windows 98 or Windows 2000, you are already familiar with multithreading. However, the Java management thread makes multithreading particularly convenient because many of the details are easy to handle for you.
Series Articles:
Java know how much (top)
Java know how much (interface) interface
Java knows how much (40) the difference between an interface and an abstract class
Java know how much (41) generic explanation
Java know how much (42) the range of generic wildcard characters and type parameters
Java know how much (43) Exception Handling Basics
Java know how much (44) exception type
Java know how much (45) uncaught exceptions
How much Java knows (the) use of try and catch
Java know how much (47) use of multiple catch statements
Java knows how much (in) the nesting of Try statements
Java know how much (a) throw: Exception throws
Java know how many () Java throws clauses
Java knows how many (or) finally
Java know how much (52) built-in exceptions
Java know how much (53) Use Java to create your own exception subclasses
Java know how much (54) assertion detailed
Java know how many (55) threads