http://user.qzone.qq.com/810087456/infocenter

ymecho

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
#include "stdafx.h"
#include<iostream>
using namespace std;
#include <windows.h>

#include <stdio.h>  
#include <process.h>  


int a=1;
int b=1;


unsigned int __stdcall thread_fun1(void *param)
{   

    return 0;
}
DWORD WINAPI fun2(LPVOID lpParamter)
{
   a=a--;
   return NULL;
}
int main(int argc, char* argv[])
{
   

       HANDLE hThread =  (HANDLE)_beginthreadex(0,0,&thread_fun1,0,0,0); //thread 1
       WaitForSingleObject(hThread,INFINITE);
     
       HANDLE hThread2 = CreateThread(NULL, 0, fun2, NULL, 0, NULL);
       CloseHandle(hThread2);

        HANDLE hThread3 = CreateThread(NULL, 0, fun2, NULL, 0, NULL);
        CloseHandle(hThread3);
   
      cout<<a<<endl;
      cout<<GetCurrentThreadId()<<endl;

   return 0;
}

 

posted on 2013-10-01 20:22  ymecho  阅读(162)  评论(0编辑  收藏  举报