The Threads makes us able to run multitasks at a time. In fact Computers (John von Neumann Architecture) don't execute the tasks parallel. The OS gives threads permission (depend on thread priority) to work on CPU. The sufficient degree of parallelism keeps the CPU busy and it is efficient.
Now, let us look a simple mathematical problem:
We want calculate the Integral from the function f(x) = x*x +exp(x). using trapezoid formula. We will use different threads to calculate the integral from partial functions f1(x) = x*x and f2(x) = exp(x). After the calculation we will add the values together.
This article is tested on RTM by Zhanbo Sun.