#include "pch.h"
#include <iostream>
#include <Windows.h>
using namespace std;

DWORD WINAPI ThreadFun(LPVOID lpParam)
{
	int i = 0;
	while (i < 100)
	{
		i++;
		cout << "Licznik inkrementacji watku 1 wynosi: " << i << endl;
	}


	return 0;
}

DWORD WINAPI ThreadFun2(LPVOID lpParam)
{

	int i = 0;

	while (i < 100)
	{
		i++;
		cout << "Licznik inkrementacji watku 2 wynosi: " << i << endl;
	}

	return 0;
}

int main()
{
	HANDLE hThread[2];
	DWORD ThreadID1;
	DWORD ThreadID2;

	SetPriorityClass(GetCurrentProcess(), HIGH_PRIORITY_CLASS);
	SetThreadPriority(GetCurrentThread(), -15);
	hThread[0] = CreateThread(NULL, 0, ThreadFun, NULL, 0, &ThreadID1);
	hThread[1] = CreateThread(NULL, 0, ThreadFun2, NULL, 0, &ThreadID2);


	cout << "Priorytet watku 1: " << GetThreadPriority(hThread[0]) << endl;
	cout << "Priorytet watku 2: " << GetThreadPriority(hThread[1]) << endl;

	SetThreadPriority(hThread[0], -15);
	SetThreadPriority(hThread[1], 15);

	cout << "Priorytet watku 1: " << GetThreadPriority(hThread[0]) << endl;
	cout << "Priorytet watku 2: " << GetThreadPriority(hThread[1]) << endl;

	WaitForMultipleObjects(2, hThread, TRUE, INFINITE);
	CloseHandle(hThread[0]);
	CloseHandle(hThread[1]);
}
