{"id":26525,"date":"2012-11-28T08:00:12","date_gmt":"2012-11-28T00:00:12","guid":{"rendered":"http:\/\/www.yankay.com\/?p=26525"},"modified":"2012-11-28T08:00:12","modified_gmt":"2012-11-28T00:00:12","slug":"go-clear-concurreny","status":"publish","type":"post","link":"http:\/\/yankay.com\/go-clear-concurreny\/","title":{"rendered":"Go-\u7b80\u6d01\u7684\u5e76\u53d1"},"content":{"rendered":"
\u591a\u6838\u5904\u7406\u5668\u8d8a\u6765\u8d8a\u666e\u53ca\u3002\u6709\u6ca1\u6709\u4e00\u79cd\u7b80\u5355\u7684\u529e\u6cd5\uff0c\u80fd\u591f\u8ba9\u6211\u4eec\u5199\u7684\u8f6f\u4ef6\u91ca\u653e\u591a\u6838\u7684\u5a01\u529b\uff1f\u662f\u6709\u7684\u3002\u968f\u7740Golang, Erlang, Scala\u7b49\u4e3a\u5e76\u53d1\u8bbe\u8ba1\u7684\u7a0b\u5e8f\u8bed\u8a00\u7684\u5174\u8d77\uff0c\u65b0\u7684\u5e76\u53d1\u6a21\u5f0f\u9010\u6e10\u6e05\u6670\u3002\u6b63\u5982\u8fc7\u7a0b\u5f0f\u7f16\u7a0b\u548c\u9762\u5411\u5bf9\u8c61\u4e00\u6837\uff0c\u4e00\u4e2a\u597d\u7684\u7f16\u7a0b\u6a21\u5f0f\u6709\u4e00\u4e2a\u6781\u5176\u7b80\u6d01\u7684\u5185\u6838\uff0c\u8fd8\u6709\u5728\u6b64\u4e4b\u4e0a\u4e30\u5bcc\u7684\u5916\u5ef6\u3002\u53ef\u4ee5\u89e3\u51b3\u73b0\u5b9e\u4e16\u754c\u4e2d\u5404\u79cd\u5404\u6837\u7684\u95ee\u9898\u3002\u672c\u6587\u4ee5GO\u8bed\u8a00\u4e3a\u4f8b\uff0c\u89e3\u91ca\u5176\u4e2d\u5185\u6838\u3001\u5916\u5ef6\u3002<\/p>\n
\u8fd9\u79cd\u5e76\u53d1\u6a21\u5f0f\u7684\u5185\u6838\u53ea\u9700\u8981\u534f\u7a0b<\/strong>\u548c\u901a\u9053<\/strong>\u5c31\u591f\u4e86\u3002\u534f\u7a0b\u8d1f\u8d23\u6267\u884c\u4ee3\u7801\uff0c\u901a\u9053\u8d1f\u8d23\u5728\u534f\u7a0b\u4e4b\u95f4\u4f20\u9012\u4e8b\u4ef6\u3002<\/p>\n <\/a><\/p>\n \u4e0d\u4e45\u524d\uff0c\u5e76\u53d1\u7f16\u7a0b\u662f\u4e2a\u975e\u5e38\u56f0\u96be\u7684\u4e8b\u3002\u8981\u60f3\u7f16\u5199\u4e00\u4e2a\u826f\u597d\u7684\u5e76\u53d1\u7a0b\u5e8f\uff0c\u6211\u4eec\u4e0d\u5f97\u4e0d\u4e86\u89e3\u7ebf\u7a0b\uff0c\u9501\uff0csemaphore\uff0cbarrier\u751a\u81f3CPU\u66f4\u65b0\u9ad8\u901f\u7f13\u5b58\u7684\u65b9\u5f0f\uff0c\u800c\u4e14\u4ed6\u4eec\u4e2a\u4e2a\u90fd\u6709\u602a\u813e\u6c14\uff0c\u5904\u5904\u662f\u9677\u9631\u3002\u7b14\u8005\u9664\u975e\u4e07\u4e0d\u5f97\u4ee5\uff0c\u51b3\u4e0d\u4f1a\u81ea\u5df1\u64cd\u4f5c\u8fd9\u4e9b\u5e95\u5c42\u5e76\u53d1\u5143\u7d20\u3002\u4e00\u4e2a\u7b80\u6d01\u7684\u5e76\u53d1\u6a21\u5f0f\u4e0d\u9700\u8981\u8fd9\u4e9b\u590d\u6742\u7684\u5e95\u5c42\u5143\u7d20\uff0c\u534f\u7a0b\u548c\u901a\u9053\u5c31\u591f\u4e86\u3002<\/p>\n \u534f\u7a0b\u662f\u8f7b\u91cf\u7ea7\u7684\u7ebf\u7a0b\u3002\u5728\u8fc7\u7a0b\u5f0f\u7f16\u7a0b\u4e2d\uff0c\u5f53\u8c03\u7528\u4e00\u4e2a\u8fc7\u7a0b\u7684\u65f6\u5019\uff0c\u9700\u8981\u7b49\u5f85\u5176\u6267\u884c\u5b8c\u624d\u8fd4\u56de\u3002\u800c\u8c03\u7528\u4e00\u4e2a\u534f\u7a0b\u7684\u65f6\u5019\uff0c\u4e0d\u9700\u8981\u7b49\u5f85\u5176\u6267\u884c\u5b8c\uff0c\u4f1a\u7acb\u5373\u8fd4\u56de\u3002\u534f\u7a0b\u5341\u5206\u8f7b\u91cf\uff0cGo\u8bed\u8a00\u53ef\u4ee5\u5728\u4e00\u4e2a\u8fdb\u7a0b\u4e2d\u6267\u884c\u6709\u6570\u4ee5\u5341\u4e07\u8ba1\u7684\u534f\u7a0b\uff0c\u4f9d\u65e7\u4fdd\u6301\u9ad8\u6027\u80fd\u3002\u800c\u5bf9\u4e8e\u666e\u901a\u7684\u5e73\u53f0\uff0c\u4e00\u4e2a\u8fdb\u7a0b\u6709\u6570\u5343\u4e2a\u7ebf\u7a0b\uff0c\u5176CPU\u4f1a\u5fd9\u4e8e\u4e0a\u4e0b\u6587\u5207\u6362\uff0c\u6027\u80fd\u6025\u5267\u4e0b\u964d\u3002\u968f\u610f\u521b\u5efa\u7ebf\u7a0b\u53ef\u4e0d\u662f\u4e00\u4e2a\u597d\u4e3b\u610f\uff0c\u4f46\u662f\u6211\u4eec\u53ef\u4ee5\u5927\u91cf\u4f7f\u7528\u7684\u534f\u7a0b\u3002<\/p>\n \u901a\u9053\u662f\u534f\u7a0b\u4e4b\u95f4\u7684\u6570\u636e\u4f20\u8f93\u901a\u9053\u3002\u901a\u9053\u53ef\u4ee5\u5728\u4f17\u591a\u7684\u534f\u7a0b\u4e4b\u95f4\u4f20\u9012\u6570\u636e\uff0c\u5177\u4f53\u53ef\u4ee5\u503c\u4e5f\u53ef\u4ee5\u662f\u4e2a\u5f15\u7528\u3002\u901a\u9053\u6709\u4e24\u79cd\u4f7f\u7528\u65b9\u5f0f\u3002<\/p>\n \u5982\u6b64\uff0c\u901a\u9053\u5c31\u53ef\u4ee5\u5728\u4f20\u9012\u6570\u636e\u7684\u540c\u65f6\uff0c\u63a7\u5236\u534f\u7a0b\u7684\u8fd0\u884c\u3002\u6709\u70b9\u50cf\u4e8b\u4ef6\u9a71\u52a8\uff0c\u4e5f\u6709\u70b9\u50cf\u963b\u585e\u961f\u5217\u3002<\/p>\n \u8fd9\u4e24\u4e2a\u6982\u5ff5\u975e\u5e38\u7684\u7b80\u5355\uff0c\u5404\u4e2a\u8bed\u8a00\u5e73\u53f0\u90fd\u4f1a\u6709\u76f8\u5e94\u7684\u5b9e\u73b0\u3002\u5728Java\u548cC\u4e0a\u4e5f\u5404\u6709\u5e93\u53ef\u4ee5\u5b9e\u73b0\u4e24\u8005\u3002<\/p>\n\n