/* related posts with thumb nails */

What is Multithreading:

Multithreading is a programming ability to perform multiple process in parallel based on time-sharing technique. Thread is a task or flow of execution that can be made to run using time-sharing principle. It is important to remember that 'threads running in parallel' does not really mean that they actually run at the same time. Since all the threads are running on a single processor, the flow of execution is shared between the threads. The Java interpreter handles the switching of control between the threads in such a way that it appears they are running concurrently.

For example, one subprogram can display an animation on the screen while another may play music in parallel. This is something similar to dividing a task into subtasks and assigning them to different people for execution independently and simultaneously. In most of our computers, we have only a single processor and therefore, in reality, the processor is doing only one thing at a time. However, the processor switches between the processes so fast that it appears to us that all of them are being done simultaneously.

Normal programs contain only a single sequential flow of control. These are called single-threaded programs. When we execute that, the program begins, runs through a sequence of executions, and finally ends. At any given point of time, there is only one statement under execution. A thread is similar to a program that has a single flow of control. It has a beginning, a body, and an end, and executes commands sequentially.

A program that contains multiple flows of control is known as multithreaded program. A unique property of Java is its support for multithreading. That is, Java enables us to use multiple flows of control in developing programs.

Multithreading is a powerful programming tool that makes Java distinctly different from its fellow programming languages. Multithreading is useful in a number of ways. It enables programmers to do multiple things at one time. They can divide a long program into threads and execute them in parallel. For example, we can send tasks such as printing into the background and continue to perform some other task in the foreground. This approach would considerably improve the speed of our programs.
Related Topics:

0 comments:

Post a Comment