For example, a central processing unit (CPU) performs various complex tasks simultaneously. The processes include task such as writing and printing a document, installing software, and displaying the date and time on the status bar. All these processes are handled by separate threads.
Single-threaded process: - A process that is executed using one thread is known as single-threaded process, where the process is a running instance of a program. A single-threaded application can perform only one task at a time. You have to wait for one task to complete before another task can start.
The following figure shows a single-threaded process.
Multithreaded process: - to execute more than one task at a time, you can create multiple threads in a program. A process that creates two or more threads is called a multithreaded process. For example, any web browser, such as internet explorer is a multithreaded application. Within the browser, you can print a page in the background while you scroll the page. Similarly, you can play audio files and watch animated images at the same time. Each thread in a multithreaded process runs at the same time and maintains a different execution flow.
The following figure shows a multithreaded process with two threads.