Ticket Selling System
C++
Demo1: Create a basic thread
#include "stdafx.h"
#include <windows.h>
#include <iostream>
using namespace std;
//线程函数
DWORD WINAPI ThreadProc(LPVOID lpParameter)
{
for (int i = 0; i < 5; ++ i)
{
cout << "子线程:i = " << i << endl;
Sleep(100);
}
return 0L;
}
int main()
{
//创建一个线程
HANDLE thread = CreateThread(NULL, 0, ThreadProc, NULL, 0, NULL);
//关闭线程
CloseHandle(thread);
//主线程的执行路径
for (int i = 0; i < 5; ++ i)
{
cout << "主线程:i = " << i << endl;
Sleep(100);
}
return 0;
}
---------------------
作者:luoweifu
来源:CSDN
原文:https://blog.csdn.net/luoweifu/article/details/46835437
版权声明:本文为博主原创文章,转载请附上博文链接!Demo2: Passing arguments into thread
Demo3: Thread synchronization
Demo 4: Ticket Selling System
Python
Last updated