⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dynamite.cpp

📁 window下的多线程编程参考书。值得一读
💻 CPP
字号:
//
// FILE: Dynamite.cpp
//
// Copyright (c) 1997 by Aaron Michael Cohen and Mike Woodring
//
/////////////////////////////////////////////////////////////////////////

#include <windows.h>
#include <stdio.h>
#include "DynamiteThread.h"

void main( void )
{
    // The DynamiteThreadHandler object will be the handler for
    // the new thread that will be created when the constructor
    // for the DynamiteThread object is executed.
    //
    CDynamiteThread DynamiteThreadHandler;
    CMclThread      DynamiteThread(&DynamiteThreadHandler);

    // Our new dynamite thread was started when the constructor
    // for DynamiteThread ran.  We'll wait for the thread to
    // become signaled, indicating that the thread has exited.
    //
    printf(
        "[tid 0x%08lx] Waiting for dynamite thread to exit...\n",
        GetCurrentThreadId()
    );
    
    DynamiteThread.Wait(INFINITE);
    
    // Determine why the thread exited.
    //
    DWORD dwExitCode;

    if( DynamiteThread.GetExitCode(&dwExitCode) )
    {
        printf(
            "[tid 0x%08lx] Dynamite thread has exited with exit code 0x%x\n",
            GetCurrentThreadId(),
            dwExitCode
        );
    }
    else
    {
        printf(
            "[tid 0x%08lx] Dynamite thread has exited -  code not available.\n",
            GetCurrentThreadId()
        );
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -