读书人

由单道批处理系统转化为多道批处理系统

发布时间: 2012-12-23 11:28:15 作者: rapoo

由单道批处理系统转化为多道批处理系统所存在问题的代码理解

// Demo.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "Demo.h"#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE[] = __FILE__;#endif/////////////////////////////////////////////////////////////////////////////// The one and only application object CWinApp theApp; using namespace std; static void sub(void *c);int _tmain(int argc, TCHAR* argv[], TCHAR* envp[]){    int nRetCode = 0;    /*//initialize MFC and print and error on failureif (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)){//TODO: change error code to suit your needscerr<< _T("Fatal Error: MFC initialization failed") << endl;nRetCode=1;}else{//TODO: code your application's behavior here.CString strHello;strHello.LoadString(IDS_HELLO);cout << (LPCTSTR)strHello << endl;}*/       char val='a';   char cb='A';   unsigned long v;   HANDLE ha[2];   ha[0]=::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)sub,&val,0,&v);   ha[1]=::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)sub,&cb,0,&v);   ::WaitForMultipleObjects(1,ha,true,INFINITE);       return nRetCode;}  static void sub(void *c) {  char *p=(char *)c;  char b;  for(int i=0;i<26;i++)  {      //cout<<*p<<endl;  b=*p+i;  Sleep(88);  //cout<<b<<endl;      //cout<<(*p+i)<<endl;      putchar(*p+i);   }}

读书人网 >编程

热点推荐