一个简单的C/C++多线程

来源:互联网 发布:淘宝供货商怎么找免费 编辑:程序博客网 时间:2024/06/06 06:46
#include "stdafx.h"#include"process.h"#include"stdlib.h"#include"stdio.h"#include "windows.h"int count = 0;void Add(void*);void Print(void*);int main(){_beginthread(Add, 0, NULL);_beginthread(Print, 0, NULL);_endthread();_endthread();}void Add(void*){while (true){count++;Sleep(1000);}}void Print(void*){while (1){printf("%d\n", count);Sleep(500);}}







0 0
原创粉丝点击