_beginthread()没效果呢?

fslt1981 2006-09-20 02:51:01
#include <windows.h>
#include <process.h> /* _beginthread, _endthread */
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
ofstream out("out.txt");
void ThreadFunc1(PVOID param)
{
while(1)

{
out<<"This was draw by thread l"<<endl;
}

}
void ThreadFunc2(PVOID param)
{
while(1)
{
out<<"This was draw by thread 2"<<endl;
}
}
void ThreadFunc3(PVOID param)
{
while(1)
{
out<<"This was draw by thread 3"<<endl;
}
}
void ThreadFunc4(PVOID param)
{
while(1)
{
out<<"This was draw by thread 4"<<endl;
}
}
int main(int argc, char* argv[])
{

_beginthread(ThreadFunc1,0,NULL);
_beginthread(ThreadFunc2,0,NULL);

_beginthread(ThreadFunc3,0,NULL);
_beginthread(ThreadFunc4,0,NULL);
Sleep(1000);
out<<"end";
return 0;
}

编译都通过了怎么不显示东西呢?
...全文
78 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
sankt 2006-09-20
  • 打赏
  • 举报
回复
我这里没有问题啊

out.txt里面内容如下:

This was draw by thread lThis was draw by thread 2This was draw by thread 3This was draw by thread 4



This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
This was draw by thread l
This was draw by thread 2
This was draw by thread 3
This was draw by thread 4
end

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧