资源简介
很好的多线程同步测试程序,能让你深入理解多线程以及多线程的同步问题.
![](http://www.nz998.com/pic/64818.jpg)
代码片段和文件信息
// mutexesDlg.cpp : implementation file
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
//
// This sample application is derived from the Mutex application
// distributed with Jeffrey Richter‘s “Advanced Windows“ programming book
// (Microsoft Press). See the book for more information about Win32
// programming topics including thread synchronization.
#include “stdafx.h“
#include “mutexes.h“
#include “mutexdlg.h“
#include “threads.h“
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// Implementation
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMutexesDlg dialog
CMutexesDlg::CMutexesDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMutexesDlg::IDD pParent)
m_mutex(FALSE NULL)
m_strNumber(_T(“0“))
{
//{{AFX_DATA_INIT(CMutexesDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINframe);
m_pCounterThread = NULL;
m_pDisplayThread = NULL;
}
void CMutexesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMutexesDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMutexesDlg CDialog)
//{{AFX_MSG_MAP(CMutexesDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_CBN_SELCHANGE(IDC_PRIORITYCLASS OnPriorityClassChange)
ON_CBN_SELCHANGE(IDC_CNTRTHRDPRIORITY OnPriorityChangeCntr)
ON_CBN_SELCHANGE(IDC_DSPYTHRDPRIORITY OnPriorityChangeDisp)
ON_WM_CLOSE()
ON_BN_CLICKED(IDC_PAUSE OnPause)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMutexesDlg message
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4221 2006-01-14 16:24 MfcMutexes\General.dsp
文件 537 2005-06-12 21:20 MfcMutexes\General.dsw
文件 140288 2008-06-11 15:18 MfcMutexes\General.ncb
文件 55808 2008-06-11 15:18 MfcMutexes\General.opt
文件 1391 2008-06-11 15:18 MfcMutexes\General.plg
文件 9605 2006-10-18 11:25 MfcMutexes\mutexdlg.cpp
文件 1970 2006-03-01 08:42 MfcMutexes\mutexdlg.h
文件 21552 2008-05-27 15:22 MfcMutexes\mutexes.aps
文件 1897 2008-06-11 15:18 MfcMutexes\mutexes.clw
文件 2615 2005-06-12 21:17 MfcMutexes\mutexes.cpp
文件 1593 2005-06-12 21:17 MfcMutexes\mutexes.h
文件 5937 2006-08-17 14:04 MfcMutexes\mutexes.rc
文件 903 2005-06-12 21:17 MfcMutexes\mutexes.sln
文件 6711 2005-06-12 21:17 MfcMutexes\mutexes.vcproj
文件 1078 2005-06-12 21:17 MfcMutexes\res\mutexes.ico
文件 399 2005-06-12 21:17 MfcMutexes\res\mutexes.rc2
..A.SH. 3072 2008-06-11 15:25 MfcMutexes\res\Thumbs.db
文件 1000 2006-08-17 14:04 MfcMutexes\resource.h
文件 892 2005-06-12 21:17 MfcMutexes\stdafx.cpp
文件 1153 2005-06-12 21:17 MfcMutexes\stdafx.h
文件 4642 2007-08-21 11:21 MfcMutexes\threads.cpp
文件 2665 2005-06-12 21:17 MfcMutexes\threads.h
目录 0 2008-06-11 15:25 MfcMutexes\Debug
目录 0 2008-06-11 15:25 MfcMutexes\res
目录 0 2008-06-11 15:24 MfcMutexes
----------- --------- ---------- ----- ----
269929 25
评论
共有 条评论