Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include <SDKDDKVer.h>
- #include <tchar.h>
- #include <windows.h>
- #include <conio.h>
- #include <stdio.h>
- #include <iostream>
- using namespace std;
- DWORD WINAPI AddA(LPVOID iNumA)
- {
- cout << "Thread A is started." <<"No_1"<< endl;
- return 0;
- }
- DWORD WINAPI AddB(LPVOID iNumB)
- {
- cout << "Thread B is started."<<"No_2" << endl;
- return 0;
- }
- DWORD WINAPI AddC(LPVOID iNumC)
- {
- cout << "Thread C is started." <<"No_3"<< endl;
- return 0;
- }
- DWORD WINAPI AddD(LPVOID iNumD)
- {
- cout << "Thread A is started." <<"No_4"<< endl;
- return 0;
- }
- DWORD WINAPI AddE(LPVOID iNumE)
- {
- cout << "Thread A is started." <<"No_5"<< endl;
- return 0;
- }
- int main()
- {
- HANDLE AhThread;
- DWORD AIDThread;
- HANDLE BhThread;
- DWORD BIDThread;
- HANDLE ChThread;
- DWORD CIDThread;
- HANDLE DhThread;
- DWORD DIDThread;
- HANDLE EhThread;
- DWORD EIDThread;
- AhThread = CreateThread(NULL, 0, AddA, NULL, 0, &AIDThread);
- SetThreadPriority(AhThread,THREAD_PRIORITY_BELOW_NORMAL );
- WaitForSingleObject(AhThread, INFINITE);
- cout<<"A PRIORITY:"<<GetThreadPriority(AhThread)<< "\n";
- BhThread = CreateThread(NULL, 0, AddB, NULL, 0, &BIDThread);
- SetThreadPriority(BhThread,THREAD_PRIORITY_NORMAL);
- WaitForSingleObject(BhThread, INFINITE);
- cout<<"B PRIORITY:"<<GetThreadPriority(BhThread)<< "\n";
- ChThread = CreateThread(NULL, 0, AddC, NULL, 0, &CIDThread);
- SetThreadPriority(ChThread, THREAD_PRIORITY_HIGHEST);
- WaitForSingleObject(ChThread, INFINITE);
- cout<<"C PRIORITY:"<<GetThreadPriority(ChThread)<< "\n";
- DhThread = CreateThread(NULL, 0, AddD, NULL, 0, &DIDThread);
- SetThreadPriority(DhThread, THREAD_PRIORITY_NORMAL);
- WaitForSingleObject(DhThread, INFINITE);
- cout<<"D PRIORITY:"<<GetThreadPriority(DhThread)<< "\n";
- EhThread = CreateThread(NULL, 0, AddE, NULL, 0, &EIDThread);
- SetThreadPriority(EhThread, THREAD_PRIORITY_NORMAL);
- WaitForSingleObject(EhThread, INFINITE);
- cout<<"E PRIORITY:"<<GetThreadPriority(EhThread)<< "\n";
- TerminateThread( AhThread,0);
- //ExitThread(0);
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment