Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <Windows.h>
- #include <stdio.h>
- using namespace std;
- /*
- long int* X = NULL;
- long int* Y = NULL;
- long int* Z = NULL;
- */
- long int X=0;
- long int Y=0;
- long int Z=0;
- DWORD WINAPI watekX(void *v)
- {
- while (true)
- {
- X++;
- }
- }
- DWORD WINAPI watekY(void *v)
- {
- while (true)
- {
- Y++;
- }
- }
- DWORD WINAPI watekZ(void *v)
- {
- while (true)
- {
- Z++;
- }
- }
- int main()
- {
- DWORD id0,id1,id2;
- //calloc(3, sizeof(long int*));
- HANDLE hnX, hnY, hnZ;
- hnX = CreateThread(NULL, 0, watekX, 0, 0, &id0);
- hnY = CreateThread(NULL, 0, watekY, 0, 0, &id1);
- hnZ = CreateThread(NULL, 0, watekZ, 0, 0, &id2);
- SetThreadPriority(hnX, 2);
- SetThreadPriority(hnY, 3);
- SetThreadPriority(hnZ, 2);
- while (true)
- {
- //Podstawy 0.
- //watekX();
- //watekY();
- //watekZ();
- /* //Zadanie 1.
- ResumeThread(hnX);
- ResumeThread(hnY);
- SuspendThread(hnY);
- ResumeThread(hnZ);
- */
- Sleep(10);
- printf("X = %d | Y = %d | Z = %d\n", X, Y, Z);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment