Wednesday, March 3, 2021

Multithreaded operations with the Task Parallel Library

 Async Vs Parallel Programming

Asynchronous Programming
  • Task Runs asynchronously however it is dependent on task results and wait for task to get completed. For e.g Operation that calculated Average on large set of data. Now these calculations will happen asynchronously while it wait for complete all its task.
  • Async Task run or executes on SINGLE thread
  • It is wait dependent







Parallel Task Programming

Threads are the virtual components or codes, which divides the physical core of a CPU into virtual multiple cores. A single CPU core can have up-to 2 threads per core.

CPU is dual core (i.e., 2 cores) it will have 4 threads. And if a CPU is Octal core (i.e., 8 core) it will have 16 threads and vice-versa.
     CPU----1 Core--------2 Threads
The thread is created by a process. Every time you open an application, it itself creates a thread which will handle all the tasks of that specific application. Like-wise the more application you open more threads will be created.

For eg. Two thread you can listen to music at the same time you can update a powerpoint presentation.




No comments :