51c
posts - 2,  comments - 0,  trackbacks - 0

// test2.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <stdio.h>
#include <Windows.h>
#include <ctime>
#include <cstdlib>
#include <process.h>

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

bool g_run = true;     //是否运行
using namespace std;

void userInput(void*)    //监视输入的线程函数
{
 while (true)
 {
  printf("\n %d",2);
  //cout<<"hello"<<endl;;
  //if (getchar()=='\n')  //是否输入回车
  //{
  // g_run = !g_run;   //回车运行 回车暂停

  //}
  Sleep(500);     //延迟
 }
}

void userInput2(void*)    //监视输入的线程函数
{
 while (true)
 {
  printf("\n %d",5);
  //cout<<"hello"<<endl;;
  //if (getchar()=='\n')  //是否输入回车
  //{
  // g_run = !g_run;   //回车运行 回车暂停

  //}
  Sleep(500);     //延迟
 }
}
int _tmain(int argc, _TCHAR* argv[])
{
 printf("hello world");
  _beginthread(userInput,0,NULL); //开线程
  _beginthread(userInput2,0,NULL); //开线程


 


srand(time(0));
  while (true)
 {
  if (g_run)
  {
   //system("cls");   //清屏
   int t = rand() % 1000+ 1;//1-1000的随机数
   printf("\n %d",t);  //输出
  }
  Sleep(500);     //延迟50毫秒
 }

 return 0;
}

posted on 2011-08-12 16:44 王万源 阅读(577) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理



<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

常用链接

留言簿

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜