?? madmadworld.cpp
字號:
//
// FILE: MadMadWorld.cpp
//
// Copyright (c) 1997 by Aaron Michael Cohen and Mike Woodring
//
/////////////////////////////////////////////////////////////////////////
#include <CMclGlobal.h>
#include <CMclThread.h>
#include <CMclEvent.h>
#include <CMclWaitableCollection.h>
#include <stdio.h>
#include "CWorkerThreadHandler.h"
#include "CMADThreadHandler.h"
void main( int iNumArgs )
{
printf(
"[0x%08lx] MadMadWorld starting up.\n",
GetCurrentThreadId()
);
// Create the event that will be used to tell all our threads
// (including the MAD thread) to exit normally.
//
CMclEvent ExitEvent(TRUE, FALSE);
// Create the MAD thread.
//
CMADThreadHandler MADThreadHandler(ExitEvent);
CMclThread MADThread(&MADThreadHandler);
// Create the first worker thread.
//
CWorkerThreadHandler ThreadHandler1(ExitEvent, FALSE);
CMclThread Thread1(&ThreadHandler1);
// Create the second worker thread (the one that might fault).
//
CWorkerThreadHandler ThreadHandler2(ExitEvent, (iNumArgs > 1));
CMclThread Thread2(&ThreadHandler2);
// Do some work for 10 seconds.
//
Sleep(10000);
printf(
"[0x%08lx] MadMadWorld notifying worker threads to exit.\n",
GetCurrentThreadId()
);
// Tell the MAD and worker threads to exit.
//
ExitEvent.Set();
// Wait for the threads to exit before terminating the process.
//
CMclWaitableCollection AppThreads;
AppThreads.AddObject(MADThread);
AppThreads.AddObject(Thread1);
AppThreads.AddObject(Thread2);
AppThreads.Wait(TRUE, INFINITE);
printf(
"[0x%08lx] MadMadWorld exiting.\n",
GetCurrentThreadId()
);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -