b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

windows多线程编程_python的优点_windows多线程编程实例(6)

电脑杂谈  发布时间:2017-05-28 11:01:50  来源:网络整理

第二个demo.

/*******************************************************

*

* deom2---四个线程同时写一个文件( 有参数 )

*

*

***********************************************************/

#i nclude <windows.h>

#i nclude <process.h> /* _beginthread, _endthread */

#i nclude <iostream>

#i nclude <fstream>

#i nclude <string>

using namespace std;

ofstream out("out.txt");

void ThreadFunc1(PVOID param)

{

while(1)

{

char *p;

p=(char *) param;

Sleep(10);

out<<p<<"This was draw by thread l"<<endl;

}

}

void ThreadFunc2(PVOID param)

{

while(1)

{

Sleep(10);

out<<"This was draw by thread 2"<<endl;

}

}

void ThreadFunc3(PVOID param)

{

while(1)

{

Sleep(10);

out<<"This was draw by thread 3"<<endl;

}

}

void ThreadFun(PVOID param)

{

while(1)

{

Sleep(10);

out<<"This was draw by thread 4"<<endl;

}

}

int main()

{

char *pstr=" 参数传递成功";

_beginthread(ThreadFunc1,0,pstr);

_beginthread(ThreadFunc2,0,NULL);

_beginthread(ThreadFunc3,0,NULL);

_beginthread(ThreadFun,0,NULL);

Sleep(1000);

out<<"end";

return 0;

}

// demo2 end ------------------------------------------------

第三个demo( 一个win32 应用程序 )

/*******************************************************

*

* deom3--- 在屏幕上随机画出一系列矩形

*

*

***********************************************************/

#i nclude <windows.h>

#i nclude <process.h>

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

HWND hwnd ;


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/ruanjian/article-49702-6.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...