Guest User

Untitled

a guest
Jun 14th, 2014
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. #pragma once
  2. #include <SDKDDKVer.h>
  3. #include <tchar.h>
  4. #include <windows.h>
  5. #include <conio.h>
  6. #include <stdio.h>
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. DWORD WINAPI AddA(LPVOID iNumA)
  11. {
  12. cout << "Thread A is started." <<"No_1"<< endl;
  13.  
  14.  
  15. return 0;
  16. }
  17.  
  18.  
  19. DWORD WINAPI AddB(LPVOID iNumB)
  20. {
  21. cout << "Thread B is started."<<"No_2" << endl;
  22.  
  23. return 0;
  24. }
  25.  
  26.  
  27.  
  28. DWORD WINAPI AddC(LPVOID iNumC)
  29. {
  30. cout << "Thread C is started." <<"No_3"<< endl;
  31.  
  32.  
  33. return 0;
  34. }
  35. DWORD WINAPI AddD(LPVOID iNumD)
  36. {
  37. cout << "Thread A is started." <<"No_4"<< endl;
  38.  
  39.  
  40. return 0;
  41. }
  42. DWORD WINAPI AddE(LPVOID iNumE)
  43. {
  44. cout << "Thread A is started." <<"No_5"<< endl;
  45.  
  46.  
  47. return 0;
  48. }
  49.  
  50. int main()
  51. {
  52. HANDLE AhThread;
  53. DWORD AIDThread;
  54.  
  55. HANDLE BhThread;
  56. DWORD BIDThread;
  57.  
  58. HANDLE ChThread;
  59. DWORD CIDThread;
  60.  
  61. HANDLE DhThread;
  62. DWORD DIDThread;
  63.  
  64. HANDLE EhThread;
  65. DWORD EIDThread;
  66.  
  67.     AhThread = CreateThread(NULL, 0, AddA, NULL, 0, &AIDThread);
  68.     SetThreadPriority(AhThread,THREAD_PRIORITY_BELOW_NORMAL );
  69.     WaitForSingleObject(AhThread, INFINITE);
  70.     cout<<"A PRIORITY:"<<GetThreadPriority(AhThread)<< "\n";
  71.  
  72.    
  73.  
  74. BhThread = CreateThread(NULL, 0, AddB, NULL, 0, &BIDThread);
  75. SetThreadPriority(BhThread,THREAD_PRIORITY_NORMAL);
  76. WaitForSingleObject(BhThread, INFINITE);
  77. cout<<"B PRIORITY:"<<GetThreadPriority(BhThread)<< "\n";
  78.  
  79.  
  80.  ChThread = CreateThread(NULL, 0, AddC, NULL, 0, &CIDThread);
  81.  SetThreadPriority(ChThread, THREAD_PRIORITY_HIGHEST);
  82.  WaitForSingleObject(ChThread, INFINITE);
  83.  cout<<"C PRIORITY:"<<GetThreadPriority(ChThread)<< "\n";
  84.  
  85.  
  86.  DhThread = CreateThread(NULL, 0, AddD, NULL, 0, &DIDThread);
  87.  SetThreadPriority(DhThread, THREAD_PRIORITY_NORMAL);
  88.  WaitForSingleObject(DhThread, INFINITE);
  89.  cout<<"D PRIORITY:"<<GetThreadPriority(DhThread)<< "\n";
  90.  
  91.  EhThread = CreateThread(NULL, 0, AddE, NULL, 0, &EIDThread);
  92.  SetThreadPriority(EhThread, THREAD_PRIORITY_NORMAL);
  93.  WaitForSingleObject(EhThread, INFINITE);
  94.  cout<<"E PRIORITY:"<<GetThreadPriority(EhThread)<< "\n";
  95.  
  96.  TerminateThread( AhThread,0);
  97.  
  98.  //ExitThread(0);
  99. getch();
  100.  
  101. return 0;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment