当前位置: 首页 > news >正文

东莞设计网站建设方案百度 网站 移动端

东莞设计网站建设方案,百度 网站 移动端,珠宝网站建设要以商为本,策划公司创业计划书C多线程#xff08;一#xff09; WIN 多线程API一 简单实例比较简单的代码#xff0c;创建10个线程#xff0c;其中使第4个线程在一创建就挂起#xff0c;等到其他的线程执行的差不多的时候再使第4个线程恢复执行。#include stdio.h#include stdlib.h#i…C多线程一 WIN 多线程API 一 简单实例 比较简单的代码创建10个线程其中使第4个线程在一创建就挂起等到其他的线程执行的差不多的时候再使第4个线程恢复执行。 #include stdio.h  #include stdlib.h  #include windows.h  #define THREAD_NUM 10 DWORD WINAPI PrintThreads (LPVOID); int main ()  {      HANDLE hThread[THREAD_NUM];      DWORD dwThreadID[THREAD_NUM];      for (int i0; iTHREAD_NUM; i)      {          int isStartImmediate  0;         if(3  i)             isStartImmediate  CREATE_SUSPENDED;         hThread[i]CreateThread(NULL,                // security attributes that should be applied to the new thread,                                                                                   // this is for NT. Use NULL to get the default security attributes. Use NULL for win95                                  0,                                            // default size of 1MB can be passed by passing zero.                                  PrintThreads,                     // function name:address of the function where the new thread starts.                                 (LPVOID)i,                         // parameter(void pointer): pointer to the 32 bit parameter that will be passed into the thread                                 isStartImmediate,             // flags to control the creation of the thread. Passing zero starts the thread immediately.                                                                             // Passing CREATE_SUSPENDED suspends the thread until the ResumeThread( ) function is called.                                 dwThreadID[i]            // pointer to a 32-bit variable that receives the thread identifier.                                 );          if (hThread[i])         {              printf (Thread launched successfully/n);                         }              }      printf(Start sleep 100, and let other thread excute/n);     Sleep (100);         printf(Start sleep 100, and thread 3 excute/n);     ResumeThread(hThread[3]);          Sleep(100);     for(int i  0; iTHREAD_NUM; i)     {         if (hThread[i])         {                         CloseHandle(hThread[i]);    // You need to use this to release kernel objects when you are done using them.                                          // If a process exits without closing the thread handle,                                          // the operating system drops the reference counts for those objects.                                          // But if a process frequently creates threads without closing the handles,                                          // there could be hundreds of thread kernel objects lying around and these resource leaks can have a big hit on performance.         }      }     return (0);  }  //function PrintThreads  DWORD WINAPI PrintThreads (LPVOID num) {     for (int i0; i10; i)          printf (Thread Number is %d%d%d/n, num,num,num);      return 0; } 二 其他基本API的说明 CreateThread() 调用成功返回句柄和一个id。 CloseHandle()  关闭一个打开的对象句柄该对象句柄可以是线程句柄也可以是进程、信号量等其他内核对象的句柄. SuspendThread(HANDLE) 允许开发人员将HANDLE指定的线程挂起如果要挂起的线程占有共享资源则可能导致死锁。 ResumeThread(HANDLE)  恢复指定的线程。 TerminateThread() 立即终止线程的工作不做任何清理工作。 ExitThread() 线程函数返回时回调用次函数所以一般我们不去显示的调用。 ExitThread是推荐使用的结束一个线程的方法当调用该函数时当前线程的栈被释放然后线程终止相对于TerminateThread函数来说这样做能够更好地完成附加在该线程上的DLL的清除工作. 但是ExitThread()会导致线程在清处构造器/自动变量之前就终止所以我们最好不要显示的调用ExitThread()。
http://www.yutouwan.com/news/64747/

相关文章:

  • 营销型网站建设价格贵吗WordPress如何设置站点名称
  • 个体工商户能做网站吗提供做网站
  • 合肥网站建设合肥成都网站建设顶呱呱
  • 长沙自助模板建站网页生成app
  • 网站建设的三大原则用网站ip做代理服务器
  • 网站推广策划思路的内容龙华个人网站建设
  • 做招投标有哪些网站网站内容优化方法有哪些内容
  • 如何建立公司网站链接网站建设的提升
  • 如何把地图放到网站上营销型企业网站推广的方法有哪些
  • 国外网站公司企业logo
  • 关岭网站建设建设网站必须用dns
  • 漳州模板网站建设google商店
  • 哈尔滨哪里有做网站的网站建设昆山博敏
  • 百度收录网站链接韶关建网站
  • 有哪些可以做图的网站啊25转行做网站运营
  • 阿坝网站制作地推团队去哪里找
  • 上外贸网站建设公司做公司网站
  • 邯郸有建网站的吗此网站域名三天更换
  • 高端网站建设公司价格建筑设计公司名字大全
  • 网站建设设计方案如何制作手机网页最简单的方法
  • 太原网站排名外包河北网站建设备案价格
  • 网站流量50g发帖效果好的网站
  • 建设一个网站需要哪些余姚做网站设计的公司
  • 网站优化 流量品牌设计包括哪些内容
  • 石家庄公司网站设计中国农技推广网
  • 厦门SEO_厦门网站建设工业互联网建设
  • 专业网站建设收费安卓优化大师手机版
  • 凡科建站公司在线设计自己的签名
  • 电子商务网站开发步骤网络舆情案例
  • 外贸网站建设公司市场长沙最新招聘