// Demo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "Demo.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static 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 failure
if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
{
//TODO: change error code to suit your needs
cerr<< _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);
}
}
由单道批处理系统转化为多道批处理系统所存在问题的代码理解
最新推荐文章于 2023-11-24 00:14:47 发布