- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
#include <iostream>
#include <windows.h>
#include <pthread.h>
void * func_MyThread(void * args)
{
int S=0; //
int i;
int j;
int k;
pthread_t MyThread;
pthread_create(&MyThread,NULL,func_MyThread,NULL);
for (i=1; i <=8; i++)//
pthread_join(MyThread,NULL);
{
S +=i+1; //
}
pthread_create(&MyThread,NULL,func_MyThread,NULL);
for (j=4; j <=12; j++)//
pthread_join(MyThread,NULL);
{
S+=j; //
}
pthread_create(&MyThread,NULL,func_MyThread,NULL);
for (k=5; k<=20; k++)
pthread_join(MyThread,NULL);
{
S += k*(2*k-1);
}
{
std::cout <<"S= \t" <<S; //
return 0;//
}
студент решал задачу по распределенному программированию.
все очень серьезно.