Usually, in a standard Java program, the entire program runs as a single “thread.” What it means that if a part of the program is demanding some I/O resource, for example, to proceed further, and if that I/O resource is not available at the moment, the entire program will be waiting and won’t also execute until and unless that particular resource in demand is freed. Multithreading in java is a process of implementing multiple threads simultaneously.

By definition, multitasking is that when multiple processes share common processing resources such as a CPU. Multi-threading extends an idea of multitasking into applications where you can subdivide the specific operations within a single application into individual threads.

Each of the threads can run in parallel within the system. The OS divides the processing time not only among different applications but also among each thread within the application as well.

Multi-threading enables you to write in such a way where multiple activities can proceed concurrently in the same program.

As one can understand, this raises an issue in how fast the program gets executed. The address this issue, the concept of multithreading was developed wherein the program has multiple threads that can run in parallel.

#java #multithreading in java #java program

Java Multithreading Example | Multithreading in Java
4.05 GEEK