阅读背景:

VC中cout的一些问题

来源:互联网 

此问题为看雪上的一位兄弟提出问题如下:

#include<iostream.h>

#include<windows.h>

DWORD WINAPI ThreadFun(LPVOID arg);

DWORD i=0;

void main()

{

   HANDLE thread;

   DWORD threadid;

   thread=CreateThread(0,0,ThreadFun,&i,0,&threadid);

   cout<<"main thread"<<i++<<endl;

   Sleep(1000);

   CloseHandle(thread);

}

DWORD WINAPI ThreadFun(LPVOID arg)

{

    cout<<"my thread"<<i++<<endl;

    return 0;

}



这个程序输出的两个结果是

1.

my thread0

my thread0

main thread

Press any key to continue

2.

main thread

main thread

my thread0

Press any key to continue#include<iostream.h>

#i



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: