Why use multithreading?

Top  Previous  Next

As has already been pointed out, multithreading offers several "threads" of execution. This feature allows much easier program development as the problem can be broken down in several "sub-tasks" - threads as they are called. Multithreading will also make it easier to implement programs where different "sub-tasks" have different priorities and timing. Consider a high-speed I/O thread that takes care of the I/O handling by generating alarm messages to an SMS thread that is responsible for sending out SMS messages. It is clear that the I/O thread it not allowed to be halted because it takes time for the SMS message to be sent out. If the I/O thread blocks for a certain amount of time, it will most likely result in several input changes becoming lost with potentially severe consequences.

 

Multithreading your code can have many benefits. These include:

 

Improved application responsiveness - any program in which many activities are not dependent upon each other can be redesigned so that each activity is defined as a thread.

Improved program structure - many programs are more efficiently structured as multiple independent or semi-independent units of execution instead of as a single, monolithic thread. Multithreaded programs can be more adaptive to variations in demands than single threaded programs.

Uses fewer resources compared to multiple program tasks.

 

 

Please continue reading the section Using multithreading.