
正文
windos多线程编程
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
随机数滚动发生器
#include <stdio.h>
#include <Windows.h>
#include <ctime>
#include <process.h>
bool g_run = true;
void userInput(void*){ //监视输入的线程函数
while(true){
if(getchar() == '\n')
g_run = !g_run;
Sleep();
}
}
int main(){
srand(time()); //随机数种子
_beginthread(userInput, , NULL); //开线程
while(true){
if(g_run){
system("cls"); //清屏
+ ; //1-1000的随机数
printf("\n %d",t); //输出
}
Sleep(); //延迟50毫秒
}
;
}







