Pages

Monday, 8 July 2013

Difference between Multi Threading and Parallel Programming

In this article we can see the difference between Multi threading and parallel programmingWhy Dotnet Framework introduces Parallel Programming Even though Multi threading already exists in FrameworkThere is a major big difference is exists between the two concepts , but both are doing the multi task in concurrent way. Parallel programming is acts as higher layer of Threading.Multi ThreadingFirst Let we see about Multi Threading, Concepts,

From the above program we can invoke a 10 threads concurrently While execute the multi threading ,I monitor the CPU Performance. My computer have 4 core processcorCPU LOAD

Threads are executed in single core more , so load given to the core is not split based on balance. It is allocated based on the sequence , threads are allocated more to perform in single core , after the core is heavy load. remaining threads are then in remaining core.Allocation of thread execution in core has to be handled manually by developers and it is more complex to find which core is heavy loaded , and which core we have to execute the thread.OutPut :From the ouput you can see the time taken to finish each thread , along with thread id.

From the above code , we are creating the threads in parallel. 10 threads are running at the same time in all the core , CPU load is balanced by allocating the threads equally in all core. So Allocating the Execution of threads to the Core is handled internally by parallel programming . Parallel.For(); is one of the code which is used to execute the method in parallel.

CPU LOAD

From the above screenshot , we can find the parallel program or task library will allocate the threads in balanced manner to the core processors of system. Each Core of computer is equally loaded.OUTPUT:

From the Given output we can find that parallel programming is very fast then multi threading.Let we see another program in parallel which uses task factory class ,Allocation of thread execution in core is managed by parallel programming internally.

From this article , we can understand about the basic info of parallel programming or task library and Multi threading. Difference between Parallel programming and muilt threading is also explained clearly