Multithreading
• What is thread/multithreading
• Why multithreading
• Two examples of multithreading
Multithreading – What is thread/multithreading
Thread
A thread is an independent unit of execution created within the context of a process (or application that is being executed)
means that you have multiple threads of execution inside the same application/process. One thread is like a separate execution of your application. Therefore, a multithread application is like an application/process that has multiple executions at the same time.
Multithreading – why multithreading
Allows you to do more than one thing at same time
• Browse online shopping website
• Chat with customer service
• Download files in the background
Multithreading – Two examples of multithreading
Example 1
A multithreading example with threads running different code part
Multithreading – Two examples of multithreading
Example 2
A multithreading example with threads running same code part