Advertisement
andruhovski

OS-0202a

Sep 9th, 2016
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // OS-0201a.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <Windows.h>
  6. #include <process.h>
  7. unsigned __stdcall MyThreadFunc(void *);
  8. int _tmain(int argc, _TCHAR* argv[])
  9. {
  10.     unsigned threadID1;
  11.     unsigned threadID2;
  12.     char s1 = '1';
  13.     char s2 = '2';
  14.  
  15.     HANDLE hThread1 =
  16.         (HANDLE)_beginthreadex(NULL, 0, &MyThreadFunc, &s1, 0, &threadID1);
  17.     HANDLE hThread2 =
  18.         (HANDLE)_beginthreadex(NULL, 0, &MyThreadFunc, &s2, 0, &threadID2);
  19.     Sleep(10000);
  20.     return 0;
  21. }
  22.  
  23. unsigned __stdcall MyThreadFunc(void *symb)
  24. {
  25.     char my_symbol = *((char *)symb);
  26.     if (my_symbol == '2')
  27.         Sleep(my_symbol * 10);
  28.     for (size_t i = 0; i < 10; i++)
  29.     {
  30.         for (size_t j = 0; j < 10; j++)
  31.         {
  32.             putchar(my_symbol);
  33.         }
  34.         Sleep(my_symbol * 100);
  35.     }
  36.     _endthreadex(0);
  37.     return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement