hi everybody, i still have problems with parallel programming.
i want to solve little problem, where i have matrix 2x2 and vector consisting of 2 elements and i must multiply them using parallel programming. result will be some vector.
i want to solve this like this:
1st element will be calculated in 1 process(thread) and the second element in second process(thread) at one time. i want to do this using AfxBeginThread, but have some problems with passing arguments, here it is
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
UINT ThreadMultiply(LPVOID lp)
{
CString s;
int * pi = (int *) lp;
for(int i = 1; i < (*pi); i++)
{
s.Format( "%d", (*(pi+i)) );
AfxMessageBox(s);
}
return 1;
}
void CProgramm::OnBnClickedButton15()
{
int count[6] = {5,1,2,3,4,5};
AfxBeginThread(ThreadMultiply,count,NULL);
}
| |
i get 1, except 1 2 3 4 5
my questions:
why it happens?
is my logic right, or i don't understand what is parallel programming?
what is difference between thread and process(i already read wiki)?
thanks for answers and sorry for my english))!