The following are programming examples in which multithreading provides better performance than a single-threaded solution:
a. A Web server that services each request in a separate thread.
b. A matrix multiplication program where different parts of the matrix may be worked on in parallel.
c. An interactive GUI program such as a debugger where a thread is used to monitor user input, another thread represents the running application, and a third thread monitors performance.
On the other hand, the following are programming examples in which multithreading does NOT provide better performance than a single-threaded solution.
b. Another example is a “shell” program such as the C-shell or Korn shell. Such a program must closely monitor its own working space such as open files, environment variables, and current working directory.
Provide one programming example in which multithreading provides better performance than a single-threaded solution. Also, provide one programming example in which multithreading does NOT provide better performance than a single-threaded solution. Your answers must be specific (e.g., a tax return program and a matrix multiplication program) and different from the ones that have already been mentioned above. Clearly explain to justify your answers.
Multithreading is benificial in the situations to achieve parallelism , where even if one thread task gets halted, the other thread operations work smoothly.
Single threaded solution is generally desirable in sequential tasks where, output of one function is the input to the next one. In that case, creating multiple threads will generate more overhead.
One example where Multithreading is better :-
One example where Single -Threaded Solution is better :-
Get Answers For Free
Most questions answered within 1 hours.