#define MAX 1000000
#include <windows.h>
#include <string.h>
#include <stdio.h>
#include "md5.h"
#include <stdlib.h> //itoa
#include <assert.h> //pre assert
#include <time.h> //pre stopky
using namespace std;
DWORD WINAPI Task1(LPVOID) //thread prvy
{
printf("process nr 1. is starting...\n");
MD5 md5 ;
long int p;
char buffer[33]; //buffer pre 32 bitov
for(p=0;p<MAX;p++){
itoa(p,buffer,10); //transformacia intu na string
md5.digestString(buffer); //premena na md5
};
return 0;
}
DWORD WINAPI Task2(LPVOID) //thread druhy
{
printf("process nr 2. is starting...\n");
MD5 md5 ;
long int p;
char buffer[33]; //buffer pre 32 bitov
for(p=0;p<MAX;p++){
itoa(p,buffer,10); //transformacia intu na string
md5.digestString(buffer); //premena na md5
};
return 0;
}
int main() //funkcia main
{
HANDLE hThread1, hThread2;
DWORD dwGenericThread;
printf("Program is running please be patient...\n");
clock_t start, stop;
double t = 0.0;
assert((start = clock())!=-1);
hThread1 = CreateThread(NULL,0,Feladat1,NULL,0,&dwGenericThread);
hThread2 = CreateThread(NULL,0,Feladat2,NULL,0,&dwGenericThread);
WaitForSingleObject(hThread2,INFINITE);
stop = clock();
t = (double) (stop-start)/CLOCKS_PER_SEC;
printf("Runtime: %f\n", t);
getchar();
return 0;
}
Comments
0 B
|👍
/👎
0 B
|0 👍
/0 👎
0 B
|👍
/👎