andruhovski icon

OS-0202a

andruhovski | PRO | 09/09/16 07:13:35 AM UTC | 0 ⭐ | 10554 👁️ | Never ⏰ | []
C++ (WinAPI) |

0 B

|

None

|

0 👍

/

0 👎

// 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;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎