Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OS-0201a.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <Windows.h>
- #include <process.h>
- unsigned __stdcall MyThreadFunc(void *);
- int _tmain(int argc, _TCHAR* argv[])
- {
- unsigned threadID1;
- unsigned threadID2;
- char s1 = '1';
- char s2 = '2';
- HANDLE hThread1 =
- (HANDLE)_beginthreadex(NULL, 0, &MyThreadFunc, &s1, 0, &threadID1);
- HANDLE hThread2 =
- (HANDLE)_beginthreadex(NULL, 0, &MyThreadFunc, &s2, 0, &threadID2);
- Sleep(10000);
- return 0;
- }
- unsigned __stdcall MyThreadFunc(void *symb)
- {
- char my_symbol = *((char *)symb);
- if (my_symbol == '2')
- Sleep(my_symbol * 10);
- for (size_t i = 0; i < 10; i++)
- {
- for (size_t j = 0; j < 10; j++)
- {
- putchar(my_symbol);
- }
- Sleep(my_symbol * 100);
- }
- _endthreadex(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement