12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "Header.h"
- int n = 10;
- DWORD WINAPI ThreadFactorial(LPVOID param)
- {
- int f = 0;
- for (int i = 0; i < n; i++)
- {
- if (i == 0) f = 1;
- else f *= i;
- printf("Ôàêòîðèàë %d = %d\n", i, f);
- }
- ExitThread(0);
- }
- DWORD WINAPI ThreadFibonachi(LPVOID param)
- {
- int buf = 0;
- int f1 = 1;
- int f2 = 1;
- for (int i = 0; i < n; i++)
- {
- if (i > 2)
- {
- buf = f1;
- f1 = f2;
- f2 += buf;
- }
- printf("%d ýëåìåíò Ôèáîíà÷è = %d\n", i, f2);
- }
- ExitThread(0);
- }
- VOID funcThread(VOID)
- {
- HANDLE hT[2];
- hT[0] = CreateThread(NULL, 0, ThreadFactorial, NULL, 0, 0);
- hT[1] = CreateThread(NULL, 0, ThreadFibonachi, NULL, 0, 0);
- WaitForMultipleObjects(2, hT, TRUE, INFINITE);
- }
- void secondExemple()
- {
- funcThread();
- }
|