{"id":953,"date":"2013-08-23T23:40:27","date_gmt":"2013-08-23T15:40:27","guid":{"rendered":"http:\/\/www.youthtribe.com\/?p=953"},"modified":"2014-01-19T23:34:31","modified_gmt":"2014-01-19T15:34:31","slug":"%e5%ad%99%e9%91%ab%e8%80%81%e5%b8%88%e7%9a%84%e5%85%b3%e4%ba%8e%e7%ba%bf%e7%a8%8b%e7%9a%84%e8%ae%b2%e8%a7%a3%e5%85%b3%e9%94%ae%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"http:\/\/www.youthtribe.com\/archives\/953","title":{"rendered":"\u5b59\u946b\u8001\u5e08\u7684\u5173\u4e8e\u7ebf\u7a0b\u7684\u8bb2\u89e3\u5173\u952e\u4ee3\u7801"},"content":{"rendered":"
windows\u4e0b\u7684\u7f16\u7a0b\u4e4b\u7ebf\u7a0b\u5f88\u662f\u91cd\u8981,\u770b\u4e86\u51e0\u904d\u89c6\u9891,\u5f53\u4e0b\u53ef\u4ee5\u7528,\u53ef\u662f\u8fc7\u540e\u5c31\u53c8\u4f1a\u5fd8\u8bb0\u4e86,\u4eca\u5929\u53c8\u770b\u4e86\u4e00\u904d,\u73b0\u628a\u91cd\u8981\u4ee3\u7801\u8bb0\u4e0b\u6765,\u4ee5\u5907\u81ea\u5df1\u548c\u5927\u5bb6\u67e5\u770b.\u7528\u7684\u662fvs2010,\u548c\u89c6\u9891\u4e2d\u6709\u504f\u5dee,\u8bf7\u6ce8\u610f.<\/p>\n
\/\/ thread_learn.cpp : \u5b9a\u4e49\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9\u3002 \/\/\r\n\r\n\r\n\/\/ trick.cpp : \u5b9a\u4e49\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9\u3002\r\n\/\/\r\n\r\n#include \"stdafx.h\"\r\n#include\r\n#include\r\nusing namespace std;\r\nDWORD WINAPI Fun1Proc( LPVOID lpParameter \/\/ thread data\r\n);\r\nDWORD WINAPI Fun2Proc( LPVOID lpParameter \/\/ thread data\r\n);\r\nint tickets=1000000000;\r\nHANDLE hMutex;\r\nint _tmain(int argc, _TCHAR* argv[]) {\r\nHANDLE hThread1,hThread2;\r\nhThread1 = CreateThread(NULL,0,Fun1Proc,NULL,0,NULL);\r\n\/\/\u521b\u5efa\u7ebf\u7a0b\r\nhThread2 = CreateThread(NULL,0,Fun2Proc,NULL,0,NULL);\r\n\/\/\u521b\u5efa\u7ebf\u7a0b\r\nCloseHandle(hThread1);\/\/\u5e76\u6ca1\u6709\u7ec8\u6b62\u7ebf\u7a0b,\u597d\u50cf\u662f\u4e3a\u4e86\u5728\u7ebf\u7a0b\u7ed3\u675f\u65f6\u53ef\u4ee5\u5f7b\u5e95\u7ed3\u675f\u4ec0\u4e48\u7ebf\u7a0b\u5185\u6838\r\nCloseHandle(hThread2);\/\/\u5e76\u6ca1\u6709\u7ec8\u6b62\u7ebf\u7a0b,\u597d\u50cf\u662f\u4e3a\u4e86\u5728\u7ebf\u7a0b\u7ed3\u675f\u65f6\u53ef\u4ee5\u5f7b\u5e95\u7ed3\u675f\u4ec0\u4e48\u7ebf\u7a0b\u5185\u6838\r\nhMutex = CreateMutex(NULL,false,NULL);\/\/\u4e92\u65a5\u5bf9\u8c61\r\nSleep(4000);\r\ncout< else\r\nbreak;\r\n\/\/ReleaseMutex(hMutex);\/\/\u4ea4\u51fa\u63a7\u5236\u6743\r\nDOUBLE nR;\r\nnR = 3.1415926 *3.1415926*3.1415926*3.1415926*3.1415926*3.1415926*3.1415926;\r\nmalloc(300000000);\r\n}\r\nreturn 0;\r\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"windows\u4e0b\u7684\u7f16\u7a0b\u4e4b\u7ebf\u7a0b\u5f88\u662f\u91cd\u8981,\u770b\u4e86\u51e0\u904d\u89c6\u9891,\u5f53\u4e0b\u53ef\u4ee5\u7528,\u53ef\u662f\u8fc7\u540e\u5c31\u53c8\u4f1a\u5fd8\u8bb0\u4e86,\u4eca\u5929\u53c8\u770b\u4e86\u4e00\u904d,\u73b0\u628a\u91cd\u8981\u4ee3\u7801\u8bb0\u4e0b\u6765,\u4ee5\u5907\u81ea\u5df1\u548c\u5927\u5bb6\u67e5\u770b.\u7528\u7684\u662fvs2010,\u548c\u89c6\u9891\u4e2d\u6709\u504f\u5dee,\u8bf7\u6ce8\u610f. \/\/ thread_learn.cpp : \u5b9a\u4e49\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9\u3002 \/\/ \/\/ trick.cpp : \u5b9a\u4e49\u63a7\u5236\u53f0\u5e94\u7528\u7a0b\u5e8f\u7684\u5165\u53e3\u70b9\u3002 \/\/ #include “stdafx.h” #include #include using namespace std; DWORD WINAPI Fun1Proc( LPVOID lpParameter \/\/ thread data ); DWORD WINAPI F<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,9],"tags":[144,160,159],"_links":{"self":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/953"}],"collection":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/comments?post=953"}],"version-history":[{"count":11,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/953\/revisions"}],"predecessor-version":[{"id":955,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/953\/revisions\/955"}],"wp:attachment":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/media?parent=953"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/categories?post=953"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/tags?post=953"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}