{"id":113018,"date":"2026-10-05T11:49:18","date_gmt":"2026-10-05T03:49:18","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/113018.html"},"modified":"2026-10-05T11:49:18","modified_gmt":"2026-10-05T03:49:18","slug":"%e3%80%90%e4%bb%93%e9%a2%89%e8%af%ad%e8%a8%80%e5%85%a5%e9%97%a8-%c2%b7-%e7%ac%ac26%e8%af%be%e3%80%91","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/113018.html","title":{"rendered":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011"},"content":{"rendered":"<h2>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011\u5e76\u53d1\u57fa\u7840&#xff1a;\u7ebf\u7a0b\u7684\u521b\u5efa\u4e0e\u7b49\u5f85<\/h2>\n<p>\u524d\u9762\u7684 25 \u8bfe\u91cc&#xff0c;\u7a0b\u5e8f\u6c38\u8fdc\u662f\u4e00\u6761\u9053\u8d70\u5230\u9ed1&#xff1a;main \u4ece\u7b2c\u4e00\u884c\u6267\u884c\u5230\u6700\u540e\u4e00\u884c&#xff0c;\u4e00\u4ef6\u4e8b\u505a\u5b8c\u624d\u80fd\u505a\u4e0b\u4e00\u4ef6\u3002\u4f46\u771f\u5b9e\u4e16\u754c\u7684\u7a0b\u5e8f\u7ecf\u5e38\u8981&#034;\u540c\u65f6&#034;\u5e72\u51e0\u4ef6\u4e8b\u2014\u2014\u4e0b\u8f7d\u6587\u4ef6\u7684\u540c\u65f6\u5237\u65b0\u8fdb\u5ea6\u6761\u3001\u7b97\u4e00\u6279\u6570\u636e\u7684\u540c\u65f6\u54cd\u5e94\u7528\u6237\u70b9\u51fb\u3002\u672c\u8bfe\u8ba4\u8bc6\u4ed3\u9889\u7684\u7ebf\u7a0b&#xff1a;\u7528 spawn \u4e00\u53e5\u8bdd\u5206\u51fa\u4e00\u4e2a\u65b0\u7684\u6267\u884c\u4f53&#xff0c;\u7528 Future \u548c get() \u7b49\u5b83\u8dd1\u5b8c\u3001\u53d6\u56de\u7ed3\u679c\u3002\u5b66\u5b8c\u4f60\u4f1a\u5199\u7b2c\u4e00\u4e2a&#034;\u591a\u7ebf\u7a0b&#034;\u7a0b\u5e8f&#xff0c;\u5e76\u4e14\u4eb2\u773c\u770b\u5230\u4ed3\u9889\u5728\u7f16\u8bd1\u671f\u5c31\u62e6\u4e0b\u4e86\u4e00\u7c7b\u6700\u7ecf\u5178\u7684\u5e76\u53d1 Bug\u3002<\/p>\n<p>\u672c\u6587\u6240\u6709\u4ee3\u7801\u4e0e\u8f93\u51fa\u5747\u5728\u4ed3\u9889 SDK 1.2.0 \u4e0b\u9010\u884c\u5b9e\u6d4b\u7f16\u8bd1\u8fd0\u884c\u3002<\/p>\n<hr \/>\n<h3>\u76ee\u5f55&#xff08;\u7cfb\u5217\u5bfc\u822a&#xff09;<\/h3>\n<p>\u6574\u5957\u8def\u7ebf\u5171 7 \u4e2a\u6a21\u5757\u300130 \u8bfe&#xff1a;<\/p>\n<table>\n<tr>\u6a21\u5757\u8bfe\u6b21\u5185\u5bb9<\/tr>\n<tbody>\n<tr>\n<td>\u4e00\u3001\u73af\u5883\u4e0e\u5165\u95e8<\/td>\n<td>01&#xff5e;05<\/td>\n<td>\u73af\u5883\u642d\u5efa\u4e0e Hello World\u3001\u53d8\u91cf\u4e0e\u57fa\u672c\u7c7b\u578b\u3001\u8fd0\u7b97\u7b26\u4e0e\u8f93\u5165\u8f93\u51fa\u3001\u5206\u652f\u3001\u5faa\u73af<\/td>\n<\/tr>\n<tr>\n<td>\u4e8c\u3001\u5e38\u7528\u7c7b\u578b\u4e0e\u6570\u636e\u7ec4\u7ec7<\/td>\n<td>06&#xff5e;10<\/td>\n<td>\u5b57\u7b26\u4e32\u3001\u6570\u7ec4\u4e0e\u533a\u95f4\u3001ArrayList\/HashMap\/HashSet\u3001\u53ef\u7a7a\u7c7b\u578b\u3001\u9519\u8bef\u5904\u7406<\/td>\n<\/tr>\n<tr>\n<td>\u4e09\u3001\u51fd\u6570\u4e0e\u51fd\u6570\u5f0f<\/td>\n<td>11&#xff5e;14<\/td>\n<td>\u51fd\u6570\u3001Lambda \u4e0e\u9ad8\u9636\u51fd\u6570\u3001\u95ed\u5305\u3001\u8fed\u4ee3\u5668\u4e0e\u60f0\u6027\u5e8f\u5217<\/td>\n<\/tr>\n<tr>\n<td>\u56db\u3001\u9762\u5411\u5bf9\u8c61\u4e0e\u7c7b\u578b\u7cfb\u7edf<\/td>\n<td>15&#xff5e;20<\/td>\n<td>struct\/class\u3001\u6784\u9020\u4e0e\u5c5e\u6027\u3001\u63a5\u53e3\u3001\u679a\u4e3e\u4e0e match \u6a21\u5f0f\u5339\u914d\u3001\u6cdb\u578b\u3001\u6269\u5c55<\/td>\n<\/tr>\n<tr>\n<td>\u4e94\u3001\u5de5\u7a0b\u5316\u4e0e\u6807\u51c6\u5e93<\/td>\n<td>21&#xff5e;25<\/td>\n<td>cjpm \u5305\u7ba1\u7406\u4e0e\u591a\u6587\u4ef6\u3001\u6587\u4ef6 IO\u3001JSON \u5904\u7406\u3001\u7f51\u7edc\u7f16\u7a0b\u3001\u5355\u5143\u6d4b\u8bd5<\/td>\n<\/tr>\n<tr>\n<td>\u516d\u3001\u5e76\u53d1\u7f16\u7a0b<\/td>\n<td>26&#xff5e;28<\/td>\n<td>\u7ebf\u7a0b&#xff08;\u672c\u6587&#xff09;\u3001Channel \u901a\u9053\u4e0e\u540c\u6b65\u539f\u8bed\u3001\u5e76\u53d1\u5b9e\u6218<\/td>\n<\/tr>\n<tr>\n<td>\u4e03\u3001\u9879\u76ee\u5b9e\u6218<\/td>\n<td>29&#xff5e;30<\/td>\n<td>\u547d\u4ee4\u884c\u5c0f\u5de5\u5177\u3001GeoJSON \u6570\u636e\u5904\u7406\u5b9e\u6218<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<li>\u73af\u5883\u642d\u5efa\u4e0e\u7b2c\u4e00\u4e2a\u4ed3\u9889\u7a0b\u5e8f<\/li>\n<li>\u53d8\u91cf\u3001\u5e38\u91cf\u4e0e\u57fa\u672c\u6570\u636e\u7c7b\u578b<\/li>\n<li>\u8fd0\u7b97\u7b26\u4e0e\u6807\u51c6\u8f93\u5165\u8f93\u51fa<\/li>\n<li>\u5206\u652f\u7ed3\u6784\u4e0e match \u8868\u8fbe\u5f0f<\/li>\n<li>\u5faa\u73af\u7ed3\u6784&#xff1a;while \/ for \/ Range<\/li>\n<li>\u5b57\u7b26\u4e32\u8be6\u89e3\u4e0e\u5b57\u7b26\u4e32\u63d2\u503c<\/li>\n<li>\u6570\u7ec4 Array \u4e0e\u533a\u95f4 Range<\/li>\n<li>\u96c6\u5408\u6846\u67b6&#xff1a;ArrayList\u3001HashMap\u3001HashSet<\/li>\n<li>\u53ef\u7a7a\u7c7b\u578b ? \u4e0e Option<\/li>\n<li>\u9519\u8bef\u5904\u7406&#xff1a;\u5f02\u5e38\u673a\u5236\u4e0e Result<\/li>\n<li>\u51fd\u6570\u5b9a\u4e49\u3001\u53c2\u6570\u4e0e\u8fd4\u56de\u503c<\/li>\n<li>Lambda \u4e0e\u9ad8\u9636\u51fd\u6570<\/li>\n<li>\u95ed\u5305\u3001\u4f5c\u7528\u57df\u4e0e\u51fd\u6570\u7c7b\u578b<\/li>\n<li>\u8fed\u4ee3\u5668 Iterator \u4e0e Sequence<\/li>\n<li>\u7ed3\u6784\u4f53 struct \u4e0e\u7c7b class<\/li>\n<li>\u6784\u9020\u51fd\u6570\u3001\u5c5e\u6027\u4e0e\u65b9\u6cd5<\/li>\n<li>\u63a5\u53e3 interface \u4e0e\u5b9e\u73b0<\/li>\n<li>\u679a\u4e3e enum\u3001\u4ee3\u6570\u6570\u636e\u7c7b\u578b\u4e0e match \u6a21\u5f0f\u5339\u914d<\/li>\n<li>\u6cdb\u578b\u7f16\u7a0b<\/li>\n<li>\u6269\u5c55\u3001\u7c7b\u578b\u522b\u540d\u4e0e\u53ef\u89c1\u6027\u63a7\u5236<\/li>\n<li>cjpm \u5305\u7ba1\u7406\u4e0e\u591a\u6587\u4ef6\u9879\u76ee\u7ec4\u7ec7<\/li>\n<li>\u6587\u4ef6\u4e0e\u76ee\u5f55 IO<\/li>\n<li>JSON \u5904\u7406<\/li>\n<li>\u7f51\u7edc\u7f16\u7a0b\u5165\u95e8<\/li>\n<li>\u5355\u5143\u6d4b\u8bd5<\/li>\n<li>\u5e76\u53d1\u57fa\u7840&#xff1a;\u7ebf\u7a0b\u7684\u521b\u5efa\u4e0e\u7b49\u5f85&#xff08;\u672c\u6587&#xff09;<\/li>\n<li>Channel \u901a\u9053\u4e0e\u540c\u6b65\u539f\u8bed<\/li>\n<li>\u5e76\u53d1\u5b9e\u6218&#xff1a;\u591a\u7ebf\u7a0b\u4efb\u52a1\u5904\u7406<\/li>\n<li>\u5b9e\u6218\u4e00&#xff1a;\u5e26\u6587\u4ef6\u6301\u4e45\u5316\u7684\u547d\u4ee4\u884c\u5c0f\u5de5\u5177<\/li>\n<li>\u5b9e\u6218\u4e8c&#xff1a;GeoJSON \u6570\u636e\u5904\u7406\u7a0b\u5e8f<\/li>\n<hr \/>\n<h3>\u4e00\u3001\u4e3a\u4ec0\u4e48\u9700\u8981\u5e76\u53d1<\/h3>\n<p>\u5148\u770b\u4e00\u4e2a\u5355\u7ebf\u7a0b\u7684\u5c34\u5c2c\u573a\u666f&#xff1a;\u7a0b\u5e8f\u8981&#034;\u4e0b\u8f7d&#034;\u4e09\u4e2a\u6587\u4ef6&#xff08;\u7528 sleep \u6a21\u62df\u8017\u65f6&#xff09;&#xff0c;\u6bcf\u4e2a 1 \u79d2&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    for (i in 1..&#061;3) {<br \/>\n        sleep(Duration.second * 1)   \/\/ \u5047\u88c5\u5728\u4e0b\u8f7d<br \/>\n        println(&#034;\u6587\u4ef6 ${i} \u4e0b\u8f7d\u5b8c\u6210&#034;)<br \/>\n    }<br \/>\n    println(&#034;\u5168\u90e8\u5b8c\u6210&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>sleep \u8ba9\u5f53\u524d\u7ebf\u7a0b\u7761\u4e00\u4f1a\u513f&#xff08;\u4e0b\u4e00\u8282\u7ec6\u8bb2&#xff09;&#xff0c;Duration.second * 1 \u5c31\u662f&#034;1 \u79d2&#034;\u3002\u8fd0\u884c\u5b83&#xff0c;\u4f60\u4f1a\u770b\u7740\u5149\u6807\u5e72\u7b49 3 \u79d2\u2014\u2014\u4e09\u4e2a\u4efb\u52a1\u662f\u4e32\u884c\u7684&#xff1a;\u6587\u4ef6 2 \u5fc5\u987b\u7b49\u6587\u4ef6 1 \u4e0b\u5b8c\u624d\u5f00\u59cb\u3002<\/p>\n<p>\u4f46\u8fd9\u4e09\u4e2a\u4e0b\u8f7d\u4e92\u76f8\u4e4b\u95f4\u6beb\u65e0\u4f9d\u8d56&#xff0c;\u660e\u660e\u53ef\u4ee5\u540c\u65f6\u8fdb\u884c\u3002\u5982\u679c\u80fd&#034;\u5175\u5206\u4e09\u8def&#034;&#xff0c;\u603b\u8017\u65f6\u5e94\u8be5\u63a5\u8fd1 1 \u79d2\u800c\u4e0d\u662f 3 \u79d2\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u5e76\u53d1\u8981\u89e3\u51b3\u7684\u95ee\u9898&#xff1a;\u628a\u4e92\u4e0d\u4f9d\u8d56\u7684\u4efb\u52a1\u5206\u7ed9\u591a\u4e2a\u6267\u884c\u4f53\u540c\u65f6\u8dd1\u3002\u4ed3\u9889\u91cc\u8fd9\u4e2a&#034;\u6267\u884c\u4f53&#034;\u5c31\u662f\u7ebf\u7a0b&#xff08;thread&#xff09;\u3002<\/p>\n<p>&#x1f4cc; \u4ed3\u9889\u7ebf\u7a0b\u662f&#034;\u8f7b\u91cf\u7ea7\u7ebf\u7a0b&#034;&#xff1a;\u5b83\u7531\u4ed3\u9889\u8fd0\u884c\u65f6\u8c03\u5ea6&#xff0c;\u521b\u5efa\u548c\u5207\u6362\u7684\u5f00\u9500\u8fdc\u5c0f\u4e8e\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b&#xff0c;\u4e00\u6b21\u521b\u5efa\u6210\u767e\u4e0a\u5343\u4e2a\u4e5f\u4e0d\u662f\u95ee\u9898\u3002\u6240\u4ee5\u4ed3\u9889\u9f13\u52b1&#034;\u4e00\u4e2a\u4efb\u52a1\u4e00\u4e2a\u7ebf\u7a0b&#034;\u7684\u5199\u6cd5&#xff0c;\u4e0d\u7528\u50cf\u67d0\u4e9b\u8bed\u8a00\u90a3\u6837\u7cbe\u6253\u7ec6\u7b97\u5730\u5f00\u7ebf\u7a0b\u6c60\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001spawn&#xff1a;\u4e00\u53e5\u8bdd\u521b\u5efa\u7ebf\u7a0b<\/h3>\n<p>\u521b\u5efa\u7ebf\u7a0b\u53ea\u6709\u4e00\u4e2a\u5173\u952e\u5b57&#xff1a;spawn\u3002\u540e\u9762\u8ddf\u4e00\u5bf9\u82b1\u62ec\u53f7&#xff0c;\u62ec\u53f7\u91cc\u7684\u4ee3\u7801\u5757\u5c31\u662f\u65b0\u7ebf\u7a0b\u8981\u5e72\u7684\u4e8b&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    spawn {<br \/>\n        println(&#034;\u5b50\u7ebf\u7a0b\u5728\u8dd1&#034;)<br \/>\n    }<br \/>\n    println(&#034;\u4e3b\u7ebf\u7a0b\u7ee7\u7eed\u8d70&#034;)<br \/>\n    sleep(Duration.millisecond * 100)   \/\/ \u4e3b\u7ebf\u7a0b\u7b49\u4e00\u4e0b&#xff0c;\u539f\u56e0\u9a6c\u4e0a\u8bb2<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u67d0\u6b21\u8fd0\u884c\u7684\u8f93\u51fa&#xff1a;<\/p>\n<p>\u4e3b\u7ebf\u7a0b\u7ee7\u7eed\u8d70<br \/>\n\u5b50\u7ebf\u7a0b\u5728\u8dd1<\/p>\n<p>\u4e24\u4e2a\u5173\u952e\u89c2\u5bdf&#xff1a;<\/p>\n<li>&#034;\u4e3b\u7ebf\u7a0b\u7ee7\u7eed\u8d70&#034;\u6253\u5370\u5728\u524d\u3002spawn \u53ea\u662f&#034;\u5206\u5175&#034;&#xff0c;\u4e3b\u7ebf\u7a0b\u81ea\u5df1\u4e0d\u4f1a\u505c\u4e0b\u6765\u7b49\u2014\u2014\u5b83\u5206\u5b8c\u5175\u7acb\u523b\u6267\u884c\u4e0b\u4e00\u884c\u3002\u8fd9\u5c31\u662f&#034;\u5e76\u53d1&#034;\u4e24\u4e2a\u5b57\u7684\u76f4\u89c2\u542b\u4e49&#xff1a;\u4e24\u8def\u4eba\u9a6c\u540c\u65f6\u63a8\u8fdb\u3002<\/li>\n<li>\u591a\u8fd0\u884c\u51e0\u6b21&#xff0c;\u987a\u5e8f\u53ef\u80fd\u53cd\u8fc7\u6765\u3002\u8c01\u5148\u8dd1\u662f\u8fd0\u884c\u65f6\u8c03\u5ea6\u5668\u51b3\u5b9a\u7684&#xff0c;\u4f60\u7684\u4ee3\u7801\u4e0d\u80fd\u4f9d\u8d56\u4efb\u4f55\u56fa\u5b9a\u987a\u5e8f\u3002<\/li>\n<p>\u4f60\u53ef\u80fd\u4f1a\u95ee&#xff1a;\u6700\u540e\u90a3\u884c sleep \u662f\u5e72\u561b\u7684&#xff1f;\u8bd5\u7740\u5220\u6389\u5b83\u518d\u8fd0\u884c\u2014\u2014\u5b50\u7ebf\u7a0b\u5728\u8dd1 \u8fd9\u884c\u5b57\u4e0d\u89c1\u4e86\u3002\u539f\u56e0\u5728\u7b2c\u4e94\u8282\u8bb2&#xff0c;\u5148\u8bb0\u4f4f\u7ed3\u8bba&#xff1a;\u4e3b\u7ebf\u7a0b\u8dd1\u5b8c main \u7a0b\u5e8f\u5c31\u7ed3\u675f\u4e86&#xff0c;\u5b50\u7ebf\u7a0b\u4f1a\u88ab\u76f4\u63a5\u5e26\u8d70\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001Future \u4e0e get&#xff1a;\u7b49\u5f85\u7ebf\u7a0b\u3001\u53d6\u56de\u7ed3\u679c<\/h3>\n<p>\u5149&#034;\u5206\u5175&#034;\u4e0d\u591f&#xff0c;\u8fd8\u5f97\u80fd&#034;\u6536\u5175&#034;&#xff1a;\u7b49\u5b50\u7ebf\u7a0b\u5e72\u5b8c\u6d3b&#xff0c;\u628a\u7ed3\u679c\u62ff\u56de\u6765\u3002<\/p>\n<h4>3.1 spawn \u7684\u8fd4\u56de\u503c\u662f Future<\/h4>\n<p>spawn \u8868\u8fbe\u5f0f\u6709\u8fd4\u56de\u503c&#xff0c;\u7c7b\u578b\u662f Future&lt;T&gt;\u2014\u2014\u4e00\u4e2a&#034;\u672a\u6765\u7684\u7ed3\u679c&#034;\u3002\u82b1\u62ec\u53f7\u91cc return \u4ec0\u4e48\u7c7b\u578b&#xff0c;T \u5c31\u662f\u4ec0\u4e48\u7c7b\u578b&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    let f: Future&lt;Int64&gt; &#061; spawn {<br \/>\n        return 42        \/\/ \u5b50\u7ebf\u7a0b\u7684\u8ba1\u7b97\u7ed3\u679c<br \/>\n    }<br \/>\n    println(&#034;\u4e3b\u7ebf\u7a0b\u7ee7\u7eed\u8d70&#034;)<br \/>\n    let v &#061; f.get()       \/\/ \u7b49\u5b50\u7ebf\u7a0b\u8dd1\u5b8c&#xff0c;\u628a 42 \u62ff\u56de\u6765<br \/>\n    println(&#034;\u62ff\u5230\u7ed3\u679c&#xff1a;${v}&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u8f93\u51fa&#xff1a;<\/p>\n<p>\u4e3b\u7ebf\u7a0b\u7ee7\u7eed\u8d70<br \/>\n\u62ff\u5230\u7ed3\u679c&#xff1a;42<\/p>\n<p>get() \u7684\u8bed\u4e49\u5c31\u4e00\u53e5\u8bdd&#xff1a;\u5982\u679c\u7ebf\u7a0b\u8fd8\u6ca1\u8dd1\u5b8c&#xff0c;\u5f53\u524d\u7ebf\u7a0b\u5c31\u505c\u4e0b\u6765\u7b49\u5b83&#xff1b;\u8dd1\u5b8c\u4e86\u5c31\u628a\u7ed3\u679c\u53d6\u51fa\u6765\u3002\u8fd9\u5c31\u662f\u5176\u4ed6\u8bed\u8a00\u91cc\u5e38\u53eb join \u7684\u90a3\u4e2a\u64cd\u4f5c\u3002<\/p>\n<p>\u7c7b\u578b\u6807\u6ce8 let f: Future&lt;Int64&gt; \u4e0d\u662f\u5fc5\u987b\u7684&#xff0c;\u7f16\u8bd1\u5668\u63a8\u5f97\u51fa\u6765&#xff1b;\u4f46\u5199\u51fa\u6765\u80fd\u5e2e\u4f60\u5efa\u7acb&#034;spawn \u8fd4\u56de Future&#034;\u7684\u5fc3\u667a\u6a21\u578b\u3002<\/p>\n<h4>3.2 \u6ca1\u6709\u8fd4\u56de\u503c\u7684\u7ebf\u7a0b<\/h4>\n<p>\u82b1\u62ec\u53f7\u91cc\u4e0d\u5199 return&#xff0c;\u7ebf\u7a0b\u7c7b\u578b\u5c31\u662f Future&lt;Unit&gt;&#xff0c;\u6b64\u65f6 get() \u7684\u4f5c\u7528\u7eaf\u7cb9\u662f&#034;\u7b49\u5b83\u5e72\u5b8c&#034;&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    let g &#061; spawn {<br \/>\n        println(&#034;\u6253\u6742\u7ebf\u7a0b&#034;)<br \/>\n    }<br \/>\n    g.get()               \/\/ \u4e0d\u8981\u7ed3\u679c&#xff0c;\u53ea\u8981\u5b83\u6253\u5370\u5b8c<br \/>\n    println(&#034;\u4e3b\u7ebf\u7a0b\u786e\u8ba4\u6253\u6742\u5b8c\u6bd5&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u8f93\u51fa&#xff08;\u8fd9\u6b21\u987a\u5e8f\u662f\u4fdd\u8bc1\u7684&#xff0c;\u56e0\u4e3a\u4e3b\u7ebf\u7a0b\u5728 get() \u5904\u7b49\u4e86&#xff09;&#xff1a;<\/p>\n<p>\u6253\u6742\u7ebf\u7a0b<br \/>\n\u4e3b\u7ebf\u7a0b\u786e\u8ba4\u6253\u6742\u5b8c\u6bd5<\/p>\n<h4>3.3 get \u53ef\u4ee5\u91cd\u590d\u8c03\u7528<\/h4>\n<p>get() \u53ea\u662f&#034;\u8bfb\u53d6\u7ed3\u679c&#034;&#xff0c;\u8bfb\u591a\u5c11\u6b21\u90fd\u884c&#xff0c;\u4e0d\u4f1a\u6d88\u8017\u6389&#xff1a;<\/p>\n<p>let f &#061; spawn { return 99 }<br \/>\nprintln(&#034;${f.get()}&#034;)   \/\/ 99<br \/>\nprintln(&#034;${f.get()}&#034;)   \/\/ \u8fd8\u662f 99<\/p>\n<hr \/>\n<h3>\u56db\u3001sleep \u4e0e Duration&#xff1a;\u8ba9\u7ebf\u7a0b\u7761\u4e00\u4f1a\u513f<\/h3>\n<p>sleep \u662f\u4ed3\u9889\u7684\u5185\u7f6e\u51fd\u6570&#xff0c;\u4e0d\u9700\u8981 import&#xff0c;\u4f5c\u7528\u662f\u8ba9\u5f53\u524d\u7ebf\u7a0b\u6682\u505c\u6307\u5b9a\u65f6\u957f\u3002\u53c2\u6570\u662f\u4e00\u4e2a Duration&#xff08;\u65f6\u957f&#xff09;&#xff0c;\u5e38\u7528\u5199\u6cd5\u662f&#034;\u5355\u4f4d \u00d7 \u6570\u91cf&#034;&#xff1a;<\/p>\n<p>sleep(Duration.second * 1)         \/\/ \u7761 1 \u79d2<br \/>\nsleep(Duration.millisecond * 100)  \/\/ \u7761 100 \u6beb\u79d2<br \/>\nsleep(Duration.minute * 2)         \/\/ \u7761 2 \u5206\u949f<\/p>\n<p>sleep \u7761\u7684\u662f\u8c03\u7528\u5b83\u7684\u90a3\u4e2a\u7ebf\u7a0b&#xff1a;\u5728\u5b50\u7ebf\u7a0b\u91cc sleep&#xff0c;\u4e3b\u7ebf\u7a0b\u7167\u5e38\u8dd1&#xff1b;\u53cd\u4e4b\u4ea6\u7136\u3002\u5229\u7528\u8fd9\u4e00\u70b9\u53ef\u4ee5\u76f4\u89c2\u770b\u5230&#034;\u4e24\u8def\u5e76\u884c&#034;&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    spawn {<br \/>\n        sleep(Duration.second * 1)<br \/>\n        println(&#034;\u5b50\u7ebf\u7a0b&#xff1a;\u6211\u7761\u4e86 1 \u79d2&#xff0c;\u521a\u9192&#034;)<br \/>\n    }<br \/>\n    println(&#034;\u4e3b\u7ebf\u7a0b&#xff1a;\u6211\u53ef\u6ca1\u7761&#034;)    \/\/ \u7acb\u523b\u6253\u5370&#xff0c;\u4e0d\u7528\u7b49 1 \u79d2<br \/>\n    sleep(Duration.second * 2)     \/\/ \u4e3b\u7ebf\u7a0b\u591a\u7761\u4e00\u4f1a\u513f&#xff0c;\u7b49\u5b50\u7ebf\u7a0b\u9192<br \/>\n    return 0<br \/>\n}<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u4e3b\u7ebf\u7a0b\u4e0e\u5b50\u7ebf\u7a0b\u7684\u5173\u7cfb&#xff1a;main \u7ed3\u675f&#xff0c;\u5168\u519b\u6536\u961f<\/h3>\n<p>\u7b2c\u4e8c\u8282\u7559\u4e0b\u7684\u60ac\u5ff5&#xff1a;main \u6700\u540e\u4e00\u884c\u6267\u884c\u5b8c&#xff0c;\u7a0b\u5e8f\u5c31\u9000\u51fa&#xff0c;\u4e0d\u7ba1\u5b50\u7ebf\u7a0b\u662f\u5426\u8dd1\u5b8c\u3002\u5b9e\u6d4b&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    spawn {<br \/>\n        sleep(Duration.second * 1)<br \/>\n        println(&#034;\u8fd9\u884c\u80fd\u6253\u5370\u5417&#xff1f;&#034;)<br \/>\n    }<br \/>\n    println(&#034;main \u7ed3\u675f&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u8f93\u51fa\u53ea\u6709\u4e00\u884c&#xff1a;<\/p>\n<p>main \u7ed3\u675f<\/p>\n<p>\u5b50\u7ebf\u7a0b\u8fd8\u5728\u7761\u89c9&#xff0c;\u8fdb\u7a0b\u5df2\u7ecf\u7ed3\u675f\u4e86&#xff0c;\u90a3\u884c\u6253\u5370\u6c38\u8fdc\u6ca1\u673a\u4f1a\u6267\u884c\u3002<\/p>\n<p>\u26a0\ufe0f \u7ecf\u9a8c\u6cd5\u5219&#xff1a;\u53ea\u8981\u4f60\u5e0c\u671b\u5b50\u7ebf\u7a0b\u7684\u6d3b\u88ab\u5e72\u5b8c&#xff0c;\u4e3b\u7ebf\u7a0b\u5c31\u5fc5\u987b\u7528 get() \u7b49\u5b83&#xff08;\u6216 sleep \u8db3\u591f\u7684\u65f6\u95f4\u2014\u2014\u4f46\u8fd9\u53ea\u662f\u6f14\u793a\u624b\u6cd5&#xff0c;\u6b63\u7ecf\u4ee3\u7801\u4e00\u5f8b\u7528 get()&#xff09;\u3002<\/p>\n<p>\u5b50\u7ebf\u7a0b\u7684\u53e6\u4e00\u4e2a\u95ee\u9898\u662f\u5f02\u5e38\u3002\u5b50\u7ebf\u7a0b\u91cc\u629b\u5f02\u5e38\u4f1a\u53d1\u751f\u4ec0\u4e48&#xff1f;\u5b9e\u6d4b\u7ed3\u679c\u6709\u4e24\u6761&#xff1a;<\/p>\n<li>\u5f02\u5e38\u4e0d\u4f1a\u628a\u4e3b\u7ebf\u7a0b\u5f53\u573a\u6253\u6b7b&#xff0c;\u7a0b\u5e8f\u7ee7\u7eed\u8dd1&#xff1b;<\/li>\n<li>\u8fdb\u7a0b\u7ed3\u675f\u65f6&#xff0c;\u8fd0\u884c\u65f6\u4f1a\u628a\u8fd9\u4e2a\u5f02\u5e38\u62a5\u544a\u5230\u9519\u8bef\u8f93\u51fa&#xff08;stderr&#xff09;\u2014\u2014\u5373\u4f7f\u4f60 get() \u65f6\u6355\u83b7\u4e86\u5b83&#xff0c;\u8fd9\u4efd\u62a5\u544a\u4f9d\u7136\u4f1a\u6253\u3002<\/li>\n<p>main(): Int64 {<br \/>\n    let bad &#061; spawn {<br \/>\n        throw IllegalArgumentException(&#034;\u5b50\u7ebf\u7a0b\u70b8\u4e86&#034;)<br \/>\n    }<br \/>\n    try {<br \/>\n        bad.get()<br \/>\n    } catch (e: IllegalArgumentException) {<br \/>\n        println(&#034;main \u6355\u83b7\u5230&#xff1a;${e.message}&#034;)<br \/>\n    }<br \/>\n    println(&#034;main \u6b63\u5e38\u6536\u5c3e&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u7ec8\u7aef\u91cc stdout \u662f\u5e72\u51c0\u7684&#xff08;main \u6355\u83b7\u5230&#xff1a;\u5b50\u7ebf\u7a0b\u70b8\u4e86 \/ main \u6b63\u5e38\u6536\u5c3e&#xff09;&#xff0c;\u4f46 stderr \u91cc\u4ecd\u80fd\u770b\u5230 IllegalArgumentException: \u5b50\u7ebf\u7a0b\u70b8\u4e86 \u7684\u62a5\u544a\u3002\u6240\u4ee5\u5b50\u7ebf\u7a0b\u91cc\u7684\u4ee3\u7801\u6700\u597d\u81ea\u5df1\u5904\u7406\u597d\u5f02\u5e38&#xff0c;\u522b\u5f80\u51fa\u629b\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001spawn \u7684\u6355\u83b7\u89c4\u5219&#xff1a;let \u53ef\u4ee5&#xff0c;var \u76f4\u63a5\u7f16\u8bd1\u62a5\u9519<\/h3>\n<p>spawn \u7684\u82b1\u62ec\u53f7\u662f\u4e00\u4e2a\u95ed\u5305&#xff08;\u7b2c 13 \u8bfe&#xff09;&#xff0c;\u80fd\u7528\u5916\u9762\u7684\u53d8\u91cf&#xff0c;\u4f46\u6709\u4e00\u6761\u786c\u89c4\u5219\u2014\u2014\u53ea\u5141\u8bb8\u6355\u83b7\u4e0d\u53ef\u53d8\u7684 let&#xff0c;\u6355\u83b7 var \u76f4\u63a5\u7f16\u8bd1\u5931\u8d25&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    let name &#061; &#034;\u5c0f\u660e&#034;<br \/>\n    spawn {<br \/>\n        println(&#034;${name} \u7684\u7ebf\u7a0b&#034;)   \/\/ \u2705 let \u53ef\u4ee5\u6355\u83b7<br \/>\n    }.get()<\/p>\n<p>    var count &#061; 0<br \/>\n    spawn {<br \/>\n        count &#043;&#061; 1                  \/\/ \u274c \u7f16\u8bd1\u62a5\u9519&#xff01;<br \/>\n    }<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u7f16\u8bd1\u5668\u539f\u8bdd&#xff1a;<\/p>\n<p>error: &#039;spawn&#039; expressions cannot capture mutable variables; consider using &#039;let&#039; or boxing<\/p>\n<p>\u8fd9\u4e0d\u662f\u7f16\u8bd1\u5668\u5201\u96be\u4f60&#xff0c;\u800c\u662f\u5728\u7f16\u8bd1\u671f\u6d88\u706d\u6570\u636e\u7ade\u4e89&#xff1a;\u591a\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8bfb\u5199\u540c\u4e00\u4e2a var&#xff0c;\u7ed3\u679c\u662f\u4e0d\u53ef\u9884\u6d4b\u7684&#xff08;\u4e0b\u4e00\u8282\u4f60\u4f1a\u4eb2\u773c\u770b\u5230&#xff09;\u3002\u4ed3\u9889\u7684\u9009\u62e9\u662f&#034;\u5b81\u53ef\u4e0d\u8ba9\u4f60\u5199&#xff0c;\u4e5f\u4e0d\u8ba9\u4f60\u8e29\u5751&#034;\u3002<\/p>\n<p>\u90a3\u62a5\u9519\u4fe1\u606f\u91cc\u7684 boxing \u662f\u4ec0\u4e48\u610f\u601d&#xff1f;\u770b\u7b2c\u4e03\u8282\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u6570\u636e\u7ade\u4e89\u521d\u4f53\u9a8c&#xff1a;boxing \u7ed5\u8fc7\u4e4b\u540e\u7684\u4e16\u754c<\/h3>\n<p>\u6240\u8c13 boxing&#xff08;\u88c5\u7bb1&#xff09;&#xff0c;\u5c31\u662f\u628a\u53ef\u53d8\u72b6\u6001\u585e\u8fdb\u4e00\u4e2a class \u5b9e\u4f8b\u91cc\u3002let box &#061; CounterBox() \u672c\u8eab\u4e0d\u53ef\u53d8&#xff08;\u5f15\u7528\u4e0d\u6362&#xff09;&#xff0c;\u6240\u4ee5\u80fd\u8fc7\u7f16\u8bd1&#xff1b;\u4f46 box \u6307\u5411\u7684\u5bf9\u8c61\u5185\u90e8\u662f\u53ef\u53d8\u7684\u2014\u2014\u7f16\u8bd1\u5668\u5c31\u653e\u884c\u4e86&#xff1a;<\/p>\n<p>class CounterBox {<br \/>\n    var count: Int64 &#061; 0<br \/>\n}<\/p>\n<p>main(): Int64 {<br \/>\n    let box &#061; CounterBox()<br \/>\n    let futures &#061; ArrayList&lt;Future&lt;Unit&gt;&gt;()<br \/>\n    for (_ in 1..&#061;10) {<br \/>\n        futures.add(spawn {<br \/>\n            for (_ in 1..&#061;10000) {<br \/>\n                box.count &#043;&#061; 1     \/\/ 10 \u4e2a\u7ebf\u7a0b\u540c\u65f6\u6539\u540c\u4e00\u4e2a count<br \/>\n            }<br \/>\n        })<br \/>\n    }<br \/>\n    for (f in futures) {<br \/>\n        f.get()                    \/\/ \u7b49 10 \u4e2a\u7ebf\u7a0b\u5168\u90e8\u8dd1\u5b8c<br \/>\n    }<br \/>\n    println(&#034;\u671f\u671b 100000&#xff0c;\u5b9e\u9645 ${box.count}&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>&#xff08;ArrayList \u8bb0\u5f97 import std.collection.ArrayList\u3002&#xff09;<\/p>\n<p>\u8fde\u8dd1\u4e24\u6b21\u7684\u5b9e\u6d4b\u8f93\u51fa&#xff1a;<\/p>\n<p>\u671f\u671b 100000&#xff0c;\u5b9e\u9645 33017<br \/>\n\u671f\u671b 100000&#xff0c;\u5b9e\u9645 33874<\/p>\n<p>10 \u4e2a\u7ebf\u7a0b\u5404\u52a0 10000 \u6b21&#xff0c;\u7ed3\u679c\u5e94\u8be5\u662f 100000&#xff0c;\u5b9e\u9645\u53ea\u6709 3 \u4e07\u591a&#xff0c;\u800c\u4e14\u6bcf\u6b21\u8fd0\u884c\u6570\u5b57\u90fd\u4e0d\u4e00\u6837\u3002\u8fd9\u5c31\u662f\u6570\u636e\u7ade\u4e89&#xff1a;count &#043;&#061; 1 \u5b9e\u9645\u662f&#034;\u8bfb\u51fa \u2192 \u52a0\u4e00 \u2192 \u5199\u56de&#034;\u4e09\u6b65&#xff0c;\u4e24\u4e2a\u7ebf\u7a0b\u53ef\u80fd\u8bfb\u5230\u540c\u4e00\u4e2a\u65e7\u503c&#xff0c;\u5404\u52a0\u4e00\u6b21\u5374\u53ea\u5199\u56de\u4e00\u4e2a\u7ed3\u679c&#xff0c;\u53e6\u4e00\u6b21\u52a0\u6cd5\u51ed\u7a7a\u4e22\u5931\u3002<\/p>\n<p>\u8fd9\u8282\u8bfe\u4f60\u53ea\u8981\u5efa\u7acb\u4e24\u4e2a\u8ba4\u77e5&#xff1a;<\/p>\n<li>\u4ed3\u9889\u7528&#034;\u7981\u6b62\u6355\u83b7 var&#034;\u628a\u7edd\u5927\u591a\u6570\u5171\u4eab\u53ef\u53d8\u7684\u5199\u6cd5\u6321\u5728\u4e86\u7f16\u8bd1\u671f&#xff1b;<\/li>\n<li>\u7528 class boxing \u53ef\u4ee5\u7ed5\u8fc7&#xff0c;\u4f46\u7ed5\u8fc7\u53bb\u7684\u540e\u679c\u81ea\u8d1f\u2014\u2014\u7ed3\u679c\u5c31\u662f\u4e0a\u9762\u8fd9\u79cd\u5bf9\u4e0d\u4e0a\u7684\u8d26\u3002<\/li>\n<p>\u6b63\u786e\u7684\u89e3\u6cd5&#xff08;Channel \u901a\u9053\u3001\u4e92\u65a5\u9501\u7b49\u540c\u6b65\u539f\u8bed&#xff09;\u662f\u4e0b\u4e00\u8bfe\u7684\u5185\u5bb9&#xff0c;\u8fd9\u8282\u53ea\u9700\u8981\u8bb0\u4f4f&#034;\u95ee\u9898\u957f\u4ec0\u4e48\u6837&#034;\u3002<\/p>\n<hr \/>\n<h3>\u516b\u3001\u7efc\u5408\u5b9e\u6218&#xff1a;\u591a\u7ebf\u7a0b\u5206\u6bb5\u6c42\u548c<\/h3>\n<p>\u628a\u672c\u8bfe\u77e5\u8bc6\u4e32\u6210\u4e00\u4e2a\u771f\u6b63\u80fd\u63d0\u901f\u7684\u7a0b\u5e8f&#xff1a;\u8ba1\u7b97 1 \u52a0\u5230 100 \u4e07\u3002\u5355\u7ebf\u7a0b\u662f\u4e00\u4e2a for \u5faa\u73af&#xff1b;\u591a\u7ebf\u7a0b\u7684\u601d\u8def\u662f\u5207\u86cb\u7cd5\u2014\u2014\u628a\u533a\u95f4\u5207\u6210 4 \u6bb5&#xff0c;4 \u4e2a\u7ebf\u7a0b\u5404\u7b97\u4e00\u6bb5&#xff0c;\u6700\u540e get() \u6c47\u603b&#xff1a;<\/p>\n<p>import std.collection.ArrayList<\/p>\n<p>func rangeSum(start: Int64, end: Int64): Int64 {<br \/>\n    var sum: Int64 &#061; 0<br \/>\n    for (i in start..&#061;end) {<br \/>\n        sum &#043;&#061; i<br \/>\n    }<br \/>\n    return sum<br \/>\n}<\/p>\n<p>main(): Int64 {<br \/>\n    let total &#061; 1000000<br \/>\n    let threadCount &#061; 4<br \/>\n    let step &#061; total \/ threadCount     \/\/ \u6bcf\u6bb5 250000 \u4e2a\u6570<\/p>\n<p>    \/\/ \u5355\u7ebf\u7a0b\u57fa\u7ebf<br \/>\n    let base &#061; rangeSum(1, total)<br \/>\n    println(&#034;\u5355\u7ebf\u7a0b&#xff1a;${base}&#034;)<\/p>\n<p>    \/\/ \u591a\u7ebf\u7a0b&#xff1a;\u6bcf\u6bb5\u4e00\u4e2a\u7ebf\u7a0b<br \/>\n    let futures &#061; ArrayList&lt;Future&lt;Int64&gt;&gt;()<br \/>\n    for (k in 0..threadCount) {<br \/>\n        let start &#061; k * step &#043; 1       \/\/ \u6bcf\u6bb5\u7684\u8d77\u6b62\u90fd\u662f let&#xff0c;\u53ef\u5b89\u5168\u6355\u83b7<br \/>\n        let end &#061; (k &#043; 1) * step<br \/>\n        futures.add(spawn {<br \/>\n            return rangeSum(start, end)<br \/>\n        })<br \/>\n    }<br \/>\n    var sum: Int64 &#061; 0<br \/>\n    for (f in futures) {<br \/>\n        sum &#043;&#061; f.get()                 \/\/ \u9010\u4e2a\u6536\u5175&#xff0c;\u628a 4 \u6bb5\u52a0\u8d77\u6765<br \/>\n    }<br \/>\n    println(&#034;\u591a\u7ebf\u7a0b&#xff1a;${sum}&#034;)<br \/>\n    println(&#034;\u7ed3\u679c\u4e00\u81f4&#xff1a;${sum &#061;&#061; base}&#034;)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u5b9e\u6d4b\u8f93\u51fa&#xff1a;<\/p>\n<p>\u5355\u7ebf\u7a0b&#xff1a;500000500000<br \/>\n\u591a\u7ebf\u7a0b&#xff1a;500000500000<br \/>\n\u7ed3\u679c\u4e00\u81f4&#xff1a;true<\/p>\n<p>\u4e09\u4e2a\u7ec6\u8282\u503c\u5f97\u54c1\u5473&#xff1a;<\/p>\n<ul>\n<li>\u6bcf\u4e2a\u7ebf\u7a0b\u62ff\u5230\u81ea\u5df1\u7684 start \/ end&#xff1a;\u5b83\u4eec\u662f\u5faa\u73af\u91cc\u65b0\u7b97\u7684 let&#xff0c;\u4e0d\u5b58\u5728\u5171\u4eab&#xff0c;\u7f16\u8bd1\u5668\u653e\u884c&#xff0c;\u8fd0\u884c\u4e5f\u5b89\u5168\u2014\u2014\u8fd9\u5c31\u662f&#034;\u5207\u86cb\u7cd5&#034;\u5f0f\u5e76\u53d1\u7684\u5b89\u5168\u672c\u8d28&#xff1a;\u5404\u5e72\u5404\u7684&#xff0c;\u53ea\u6c47\u5408\u7ed3\u679c&#xff1b;<\/li>\n<li>spawn \u91cc\u8c03\u7528\u4e86\u666e\u901a\u51fd\u6570 rangeSum\u2014\u2014\u7ebf\u7a0b\u4f53\u4e0d\u9650\u4e8e\u51e0\u884c println&#xff0c;\u4efb\u610f\u590d\u6742\u7684\u903b\u8f91\u90fd\u53ef\u4ee5\u653e\u8fdb\u53bb&#xff1b;<\/li>\n<li>\u6c47\u603b\u7528 f.get() \u9010\u4e2a\u7b49\u5f85\u3002\u7b2c\u4e00\u4e2a get() \u8fd4\u56de\u65f6\u5176\u4ed6\u7ebf\u7a0b\u53ef\u80fd\u8fd8\u5728\u8dd1&#xff0c;\u6ca1\u5173\u7cfb&#xff0c;\u4e0b\u4e00\u8f6e\u5faa\u73af\u518d\u7b49\u5c31\u662f\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e5d\u3001CIDE \u5b9e\u64cd&#xff1a;\u4eb2\u624b\u611f\u53d7&#034;\u987a\u5e8f\u4e0d\u4fdd\u8bc1&#034;<\/h3>\n<p>\u5728 CIDE \u91cc cjpm init &#8211;name threaddemo \u65b0\u5efa\u5de5\u7a0b&#xff0c;\u628a\u4e0b\u9762\u4ee3\u7801\u8d34\u8fdb src\/main.cj&#xff1a;<\/p>\n<p>main(): Int64 {<br \/>\n    for (i in 1..&#061;5) {<br \/>\n        spawn {<br \/>\n            println(&#034;\u7ebf\u7a0b ${i}&#034;)<br \/>\n        }<br \/>\n    }<br \/>\n    sleep(Duration.millisecond * 100)<br \/>\n    return 0<br \/>\n}<\/p>\n<p>\u70b9\u51fb\u8fd0\u884c&#xff0c;\u7136\u540e\u8fde\u6309\u4e09\u6b21\u3002\u67d0\u4e09\u6b21\u7684\u8f93\u51fa&#xff1a;<\/p>\n<p>\u7ebf\u7a0b 5<br \/>\n\u7ebf\u7a0b 2<br \/>\n\u7ebf\u7a0b 3<br \/>\n\u7ebf\u7a0b 4<br \/>\n\u7ebf\u7a0b 1<\/p>\n<p>\u7ebf\u7a0b 1<br \/>\n\u7ebf\u7a0b 2<br \/>\n\u7ebf\u7a0b 3<br \/>\n\u7ebf\u7a0b 4<br \/>\n\u7ebf\u7a0b 5<\/p>\n<p>\u7ebf\u7a0b 3<br \/>\n\u7ebf\u7a0b 1<br \/>\n\u7ebf\u7a0b 2<br \/>\n\u7ebf\u7a0b 5<br \/>\n\u7ebf\u7a0b 4<\/p>\n<p>\u4e09\u6b21\u987a\u5e8f\u5168\u4e0d\u4e00\u6837\u2014\u2014\u8fd9\u5c31\u662f&#034;\u8c03\u5ea6\u5668\u8bf4\u4e86\u7b97&#034;\u7684\u76f4\u63a5\u8bc1\u636e\u3002\u4ee5\u540e\u5199\u5e76\u53d1\u4ee3\u7801\u65f6\u8111\u5b50\u91cc\u8981\u65f6\u523b\u60ac\u7740\u8fd9\u53e5\u8bdd&#xff1a;\u4efb\u4f55\u4f9d\u8d56\u7ebf\u7a0b\u6267\u884c\u987a\u5e8f\u7684\u903b\u8f91\u90fd\u662f Bug\u3002<\/p>\n<p>\u518d\u505a\u4e00\u4e2a\u53cd\u5411\u5b9e\u9a8c&#xff1a;\u5220\u6389\u6700\u540e\u7684 sleep \u518d\u8fd0\u884c&#xff0c;5 \u884c\u8f93\u51fa\u53ef\u80fd\u53ea\u5269 2&#xff5e;3 \u884c\u751a\u81f3\u4e00\u884c\u6ca1\u6709&#xff08;\u4e3b\u7ebf\u7a0b\u5148\u8dd1\u5b8c&#xff0c;\u8fdb\u7a0b\u76f4\u63a5\u6536\u961f&#xff09;\u3002\u628a sleep \u6362\u6210\u5bf9 5 \u4e2a Future \u9010\u4e2a get()&#xff0c;\u8f93\u51fa\u7acb\u523b\u6062\u590d\u5b8c\u6574\u2014\u2014\u8fd9\u6b63\u662f\u7b2c\u4e94\u8282\u7684\u89c4\u5219\u5728\u8d77\u4f5c\u7528\u3002<\/p>\n<hr \/>\n<h3>\u5341\u3001\u5e38\u7528 API \u901f\u67e5<\/h3>\n<table>\n<tr>\u76ee\u7684\u5199\u6cd5\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u521b\u5efa\u7ebf\u7a0b<\/td>\n<td>spawn { &#8230; }<\/td>\n<td>\u8fd4\u56de Future&lt;T&gt;&#xff0c;T \u7531\u82b1\u62ec\u53f7\u91cc\u7684 return \u51b3\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>\u7b49\u5f85\u5e76\u53d6\u7ed3\u679c<\/td>\n<td>future.get()<\/td>\n<td>\u7ebf\u7a0b\u6ca1\u8dd1\u5b8c\u5c31\u963b\u585e\u7b49\u5f85&#xff1b;\u53ef\u91cd\u590d\u8c03\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u53ea\u7b49\u5f85\u4e0d\u8981\u7ed3\u679c<\/td>\n<td>future.get()<\/td>\n<td>Future&lt;Unit&gt; \u7684 get \u8fd4\u56de Unit&#xff0c;\u7eaf\u7b49\u7ed3\u675f<\/td>\n<\/tr>\n<tr>\n<td>\u7761\u7720<\/td>\n<td>sleep(Duration.second * 1)<\/td>\n<td>\u5185\u7f6e\u51fd\u6570&#xff0c;\u65e0\u9700 import&#xff0c;\u7761\u5f53\u524d\u7ebf\u7a0b<\/td>\n<\/tr>\n<tr>\n<td>\u6beb\u79d2\u7ea7\u7761\u7720<\/td>\n<td>sleep(Duration.millisecond * 100)<\/td>\n<td>Duration \u5355\u4f4d&#xff1a;second \/ millisecond \/ minute \u7b49<\/td>\n<\/tr>\n<tr>\n<td>\u5b58\u591a\u4e2a Future<\/td>\n<td>ArrayList&lt;Future&lt;Int64&gt;&gt;<\/td>\n<td>import std.collection.ArrayList<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u5341\u4e00\u3001\u5e38\u89c1\u95ee\u9898 FAQ<\/h3>\n<p>Q1&#xff1a;spawn \u9700\u8981 import \u4ec0\u4e48\u5417&#xff1f;<\/p>\n<p>\u4e0d\u9700\u8981\u3002spawn\u3001sleep\u3001Duration\u3001Future \u90fd\u5728\u7f16\u8bd1\u5668\u9ed8\u8ba4\u5bfc\u5165\u7684 std.core \u91cc&#xff0c;\u76f4\u63a5\u5199\u3002<\/p>\n<p>Q2&#xff1a;\u4e3a\u4ec0\u4e48\u6211\u7684\u5b50\u7ebf\u7a0b\u7684\u6253\u5370\u6ca1\u51fa\u73b0&#xff1f;<\/p>\n<p>\u4e5d\u6210\u662f\u4e3b\u7ebf\u7a0b\u5148\u8dd1\u5b8c main&#xff0c;\u8fdb\u7a0b\u7ed3\u675f\u4e86\u3002\u7ed9\u5b50\u7ebf\u7a0b\u7684 Future \u8c03 get()&#xff0c;\u8ba9\u4e3b\u7ebf\u7a0b\u7b49\u5b83\u3002<\/p>\n<p>Q3&#xff1a;error: &#039;spawn&#039; expressions cannot capture mutable variables \u600e\u4e48\u6539&#xff1f;<\/p>\n<p>\u4e09\u6761\u8def&#xff1a;\u2460 \u628a\u8981\u7528\u7684\u503c\u5728 spawn \u524d\u7b97\u6210 let \u518d\u6355\u83b7&#xff08;\u6700\u63a8\u8350&#xff0c;\u672c\u8bfe\u5b9e\u6218\u5c31\u662f\u8fd9\u4e48\u505a\u7684&#xff09;&#xff1b;\u2461 \u786e\u5b9e\u9700\u8981\u5171\u4eab\u53ef\u53d8\u72b6\u6001\u65f6&#xff0c;\u7528 class \u628a\u72b6\u6001\u88c5\u7bb1&#xff08;\u7b2c\u4e03\u8282&#xff09;&#xff0c;\u4f46\u8981\u81ea\u5df1\u627f\u62c5\u6570\u636e\u7ade\u4e89\u98ce\u9669&#xff0c;\u6b63\u786e\u89e3\u6cd5\u89c1\u7b2c 27 \u8bfe&#xff1b;\u2462 \u80fd\u901a\u8fc7\u53c2\u6570\/\u8fd4\u56de\u503c\u4f20\u9012\u7684&#xff0c;\u5c31\u522b\u5171\u4eab\u3002<\/p>\n<p>Q4&#xff1a;get() \u4f1a\u7b49\u591a\u4e45&#xff1f;\u5982\u679c\u5b50\u7ebf\u7a0b\u6b7b\u5faa\u73af\u4e86\u5462&#xff1f;<\/p>\n<p>\u4e00\u76f4\u7b49\u4e0b\u53bb\u3002get() \u6ca1\u6709\u8d85\u65f6\u53c2\u6570&#xff0c;\u6240\u4ee5\u7ebf\u7a0b\u4f53\u91cc\u522b\u5199\u6b7b\u5faa\u73af&#xff1b;\u9700\u8981&#034;\u5b9a\u65f6\u68c0\u67e5&#034;\u7684\u573a\u666f\u7b49\u7b2c 27 \u8bfe\u5b66\u4e86 Channel \u518d\u8bf4\u3002<\/p>\n<p>Q5&#xff1a;\u5b50\u7ebf\u7a0b\u91cc\u629b\u5f02\u5e38&#xff0c;\u7a0b\u5e8f\u4f1a\u5d29\u5417&#xff1f;<\/p>\n<p>\u4e0d\u4f1a\u5f53\u573a\u5d29\u3002\u5f02\u5e38\u4f1a\u5b58\u5728 Future \u91cc&#xff1a;\u4f60 get() \u65f6\u5b83\u629b\u7ed9\u4f60&#xff08;\u53ef\u4ee5 try-catch&#xff09;&#xff1b;\u6ca1\u4eba get()&#xff0c;\u8fdb\u7a0b\u7ed3\u675f\u65f6\u8fd0\u884c\u65f6\u4e5f\u4f1a\u628a\u5b83\u6253\u5230 stderr\u3002\u5efa\u8bae\u5b50\u7ebf\u7a0b\u5185\u90e8\u81ea\u5df1\u6d88\u5316\u5f02\u5e38\u3002<\/p>\n<p>Q6&#xff1a;\u4ed3\u9889\u7ebf\u7a0b\u5c31\u662f\u64cd\u4f5c\u7cfb\u7edf\u7ebf\u7a0b\u5417&#xff1f;<\/p>\n<p>\u4e0d\u662f\u4e00\u4e00\u5bf9\u5e94\u3002\u4ed3\u9889\u7ebf\u7a0b\u662f\u8fd0\u884c\u65f6\u8c03\u5ea6\u7684\u8f7b\u91cf\u6267\u884c\u4f53&#xff0c;\u7531\u8fd0\u884c\u65f6\u6620\u5c04\u5230\u5c11\u91cf\u7cfb\u7edf\u7ebf\u7a0b\u4e0a\u6267\u884c&#xff0c;\u6240\u4ee5\u5f00\u51e0\u767e\u4e2a\u4e5f\u5f88\u4fbf\u5b9c\u3002\u65e5\u5e38\u7f16\u7801\u4e0d\u9700\u8981\u5173\u5fc3\u8fd9\u5c42\u6620\u5c04\u3002<\/p>\n<hr \/>\n<h3>\u5341\u4e8c\u3001\u8bfe\u540e\u7ec3\u4e60<\/h3>\n<li>\n<p>\u5199\u4e00\u4e2a\u7a0b\u5e8f&#xff1a;spawn \u4e00\u4e2a\u7ebf\u7a0b\u6253\u5370 &#034;\u6211\u662f\u5b50\u7ebf\u7a0b&#034;&#xff0c;\u4e3b\u7ebf\u7a0b\u6253\u5370 &#034;\u6211\u662f\u4e3b\u7ebf\u7a0b&#034;&#xff0c;\u6700\u540e\u7528 get() \u7b49\u5f85\u5b50\u7ebf\u7a0b\u7ed3\u675f\u3002\u8fde\u8fd0\u884c\u4e09\u6b21&#xff0c;\u89c2\u5bdf\u4e24\u884c\u7684\u5148\u540e\u987a\u5e8f\u662f\u4e0d\u662f\u6bcf\u6b21\u90fd\u4e00\u6837&#xff08;\u56de\u60f3\u7b2c\u4e5d\u8282\u7684\u7ed3\u8bba&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>\u5199\u4e00\u4e2a\u51fd\u6570 func slowAdd(a: Int64, b: Int64): Future&lt;Int64&gt;&#xff1a;\u5185\u90e8 spawn \u4e00\u4e2a\u7ebf\u7a0b&#xff0c;\u5148 sleep(Duration.second * 1)&#xff08;\u6a21\u62df\u8017\u65f6\u8ba1\u7b97&#xff09;&#xff0c;\u518d return a &#043; b\u3002main \u91cc\u8c03\u7528\u5b83\u62ff Future&#xff0c;\u5148\u6253\u5370 &#034;\u8ba1\u7b97\u5df2\u6d3e\u51fa&#xff0c;\u6211\u5148\u5e72\u522b\u7684&#034;&#xff0c;\u518d get() \u62ff\u7ed3\u679c\u6253\u5370\u3002\u8fd0\u884c\u540e\u5e94\u770b\u5230&#xff1a;\u7b2c\u4e00\u884c\u7acb\u523b\u51fa\u73b0&#xff0c;\u7ea6 1 \u79d2\u540e\u7ed3\u679c\u51fa\u73b0\u3002<\/p>\n<\/li>\n<li>\n<p>\u8d77 3 \u4e2a\u7ebf\u7a0b\u5206\u522b\u8ba1\u7b97 1~100\u3001101~200\u3001201~300 \u7684\u548c&#xff08;\u63d0\u793a&#xff1a;\u7167\u7b2c\u516b\u8282\u5b9e\u6218\u7684\u601d\u8def&#xff0c;\u624b\u5199\u4e09\u4e2a spawn \u5373\u53ef&#xff0c;\u4e0d\u7528\u5faa\u73af&#xff09;&#xff0c;\u7528\u4e09\u4e2a get() \u6c47\u603b\u5e76\u6253\u5370\u603b\u548c\u3002\u671f\u671b\u8f93\u51fa 45150&#xff1b;\u591a\u8fd0\u884c\u51e0\u6b21&#xff0c;\u786e\u8ba4\u7ed3\u679c\u6bcf\u6b21\u90fd\u4e00\u6837&#xff08;\u5bf9\u6bd4\u7ec3\u4e60 1 \u7684\u987a\u5e8f\u4e0d\u7a33\u5b9a&#xff0c;\u4f53\u4f1a&#034;\u7ed3\u679c\u6c47\u5408&#034;\u548c&#034;\u6267\u884c\u987a\u5e8f&#034;\u7684\u533a\u522b&#xff09;\u3002<\/p>\n<\/li>\n<li>\n<p>&#xff08;\u89c2\u5bdf\u5b9e\u9a8c&#xff09;\u628a\u7b2c\u4e03\u8282 CounterBox \u7684\u4f8b\u5b50\u6284\u4e0b\u6765\u8fd0\u884c\u4e09\u6b21&#xff0c;\u8bb0\u5f55\u4e09\u6b21\u7684\u5b9e\u9645\u6570\u5b57&#xff1b;\u7136\u540e\u628a\u5185\u5c42\u5faa\u73af\u4ece 1..&#061;10000 \u6539\u6210 1..&#061;10 \u518d\u8fd0\u884c\u4e09\u6b21\u3002\u56de\u7b54\u4e24\u4e2a\u95ee\u9898&#xff1a;\u2460 \u5c0f\u5faa\u73af\u6b21\u6570\u65f6\u7ed3\u679c\u4e3a\u4ec0\u4e48\u7ecf\u5e38&#034;\u78b0\u5de7&#034;\u662f\u5bf9\u7684&#xff1f;\u2461 \u8fd9\u4e2a\u7a0b\u5e8f\u7684\u9519\u8bef\u80fd\u5728\u7f16\u8bd1\u671f\u53d1\u73b0\u5417&#xff1f;\u4e3a\u4ec0\u4e48&#xff1f;<\/p>\n<\/li>\n<hr \/>\n<h3>\u4e0b\u8282\u9884\u544a<\/h3>\n<p>\u672c\u8bfe\u7ed3\u5c3e\u7684 CounterBox \u60e8\u6848\u8fd8\u60ac\u7740&#xff1a;10 \u4e2a\u7ebf\u7a0b\u52a0 10 \u4e07\u6b21&#xff0c;\u7ed3\u679c\u53ea\u6709 3 \u4e07\u591a\u3002\u7b2c 27 \u8bfe Channel \u901a\u9053\u4e0e\u540c\u6b65\u539f\u8bed\u5c31\u6765\u6536\u62fe\u8fd9\u4e2a\u5c40\u9762\u2014\u2014\u4ed3\u9889\u63a8\u8350\u7684\u59ff\u52bf\u662f&#034;\u4e0d\u8981\u5171\u4eab\u72b6\u6001&#xff0c;\u6539\u7528\u901a\u4fe1&#034;&#xff1a;\u7ebf\u7a0b\u4e4b\u95f4\u901a\u8fc7 Channel \u4e92\u76f8\u53d1\u9001\u6d88\u606f&#xff0c;\u6570\u636e\u5728\u54ea\u91cc\u3001\u5f52\u8c01\u7ba1\u4e00\u76ee\u4e86\u7136&#xff1b;\u518d\u914d\u4e0a Mutex \u4e92\u65a5\u9501\u3001Atomic \u539f\u5b50\u7c7b\u578b\u7b49\u540c\u6b65\u539f\u8bed&#xff0c;\u628a\u672c\u8bfe\u5bf9\u4e0d\u4e0a\u7684\u8d26\u4e00\u7b14\u4e00\u7b14\u7b97\u5e73\u3002<\/p>\n<hr \/>\n<p>\u7cfb\u5217\u8bf4\u660e&#xff1a;\u672c\u7cfb\u5217\u57fa\u4e8e Windows \u5e73\u53f0 &#043; CIDE &#043; \u4ed3\u9889 SDK&#xff08;1.2.0&#xff09;\u7f16\u5199&#xff0c;\u6240\u6709\u4ee3\u7801\u5747\u5df2\u5b9e\u9645\u7f16\u8bd1\u8fd0\u884c\u901a\u8fc7\u3002\u5982\u9047 SDK \u7248\u672c\u5dee\u5f02\u5bfc\u81f4\u7684\u7ec6\u8282\u51fa\u5165&#xff0c;\u4ee5\u4f60\u672c\u5730\u7248\u672c\u4e3a\u51c6&#xff0c;\u6b22\u8fce\u8bc4\u8bba\u533a\u4ea4\u6d41\u3002<\/p>\n<hr \/>\n<h3>&#x1f4ac; \u9047\u5230\u95ee\u9898&#xff1f;\u626b\u7801\u8054\u7cfb\u4f5c\u8005<\/h3>\n<p>\u8ddf\u7740\u8bfe\u7a0b\u7ec3\u4e60\u65f6&#xff0c;\u5982\u679c\u5728 SDK \u5b89\u88c5\u3001\u73af\u5883\u53d8\u91cf\u914d\u7f6e\u3001\u7f16\u8bd1\u62a5\u9519\u6216\u8c03\u8bd5\u4e0a\u5361\u4f4f&#xff0c;\u6b22\u8fce\u626b\u7801\u52a0\u4f5c\u8005\u4f01\u4e1a\u5fae\u4fe1\u76f4\u63a5\u54a8\u8be2&#xff08;\u8bf7\u5907\u6ce8&#034;\u4ed3\u9889\u8bfe\u7a0b&#034;&#xff09;&#xff1a; <img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261005034917-6ac31e3d6f597.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u79bb\u7ebf\u73af\u5883\u4e0b\u56fe\u7247\u53ef\u80fd\u52a0\u8f7d\u4e0d\u51fa\u6765&#xff0c;\u4e5f\u53ef\u4ee5\u5728 CIDE \u83dc\u5355 Help \u25b8 \u8054\u7cfb\u4f5c\u8005 \/ Contact \u4e2d\u67e5\u770b\u540c\u4e00\u5f20\u4e8c\u7ef4\u7801&#xff08;\u5e94\u7528\u5185\u7f6e\u515c\u5e95\u56fe&#xff0c;\u65e0\u9700\u8054\u7f51&#xff09;\u3002<\/p>\n<hr \/>\n<h3>&#x1f4e5; \u5de5\u5177\u4e0b\u8f7d<\/h3>\n<p>\u672c\u7cfb\u5217\u5168\u7a0b\u4f7f\u7528\u7684\u4ed3\u9889 IDE \u2014\u2014 CIDE&#xff08;\u514d\u8d39\u5f00\u6e90\u3001\u793e\u533a\u7248&#xff09;&#xff1a;<\/p>\n<ul>\n<li>GitCode \u4ed3\u5e93 \/ \u5b89\u88c5\u5305\u4e0b\u8f7d&#xff1a;https:\/\/gitcode.com\/wp_upala\/cide<\/li>\n<li>\u6253\u5f00\u9875\u9762\u540e\u8fdb\u5165 \u53d1\u884c\u7248&#xff08;Releases&#xff09;&#xff0c;\u4e24\u79cd\u5305\u4efb\u9009\u5176\u4e00&#xff1a;\n<ul>\n<li>\u5b89\u88c5\u7248&#xff1a;\u4e0b\u8f7d CIDE-&lt;\u7248\u672c&gt;-x64-Setup.exe&#xff0c;\u53cc\u51fb\u5b89\u88c5&#xff0c;\u9002\u5408\u65e5\u5e38\u957f\u671f\u4f7f\u7528&#xff1b;<\/li>\n<li>\u514d\u5b89\u88c5\u7248&#xff08;Portable&#xff09;&#xff1a;\u4e0b\u8f7d CIDE-&lt;\u7248\u672c&gt;-x64-Portable.zip&#xff0c;\u89e3\u538b\u5230\u4efb\u610f\u76ee\u5f55\u5373\u7528&#xff0c;\u4e0d\u5199\u6ce8\u518c\u8868\u3001\u4e0d\u7559\u5b89\u88c5\u75d5\u8ff9&#xff0c;\u62f7\u5230 U \u76d8\u4e5f\u80fd\u5728\u522b\u7684\u7535\u8111\u76f4\u63a5\u8fd0\u884c&#xff08;\u5305\u5185\u9644\u300a\u4f7f\u7528\u8bf4\u660e.txt\u300b&#xff09;\u3002\u9002\u5408\u5148\u8bd5\u7528\u3001\u6216\u5728\u53d7\u9650\u7535\u8111\u4e0a\u5b66\u4e60\u672c\u7cfb\u5217\u8bfe\u7a0b\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u4ed3\u9889 SDK \u8bf7\u524d\u5f80\u4ed3\u9889\u7f16\u7a0b\u8bed\u8a00\u5b98\u7f51\u4e0b\u8f7d&#xff1a;https:\/\/cangjie-lang.cn<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011\u5e76\u53d1\u57fa\u7840&#xff1a;\u7ebf\u7a0b\u7684\u521b\u5efa\u4e0e\u7b49\u5f85 \u524d\u9762\u7684 25 \u8bfe\u91cc&#xff0c;\u7a0b\u5e8f\u6c38\u8fdc\u662f\u4e00\u6761\u9053\u8d70\u5230\u9ed1&#xff1a;main \u4ece\u7b2c\u4e00\u884c\u6267\u884c\u5230\u6700\u540e\u4e00\u884c&#xff0c;\u4e00\u4ef6\u4e8b\u505a\u5b8c\u624d\u80fd\u505a\u4e0b\u4e00\u4ef6\u3002\u4f46\u771f\u5b9e\u4e16\u754c\u7684\u7a0b\u5e8f\u7ecf\u5e38\u8981\\&#8221;\u540c\u65f6\\&#8221;\u5e72\u51e0\u4ef6\u4e8b\u2014\u2014\u4e0b\u8f7d\u6587\u4ef6\u7684\u540c\u65f6\u5237\u65b0\u8fdb\u5ea6\u6761\u3001\u7b97\u4e00\u6279\u6570\u636e\u7684\u540c\u65f6\u54cd\u5e94\u7528\u6237\u70b9\u51fb\u3002\u672c\u8bfe\u8ba4\u8bc6\u4ed3\u9889\u7684\u7ebf\u7a0b&#xff1a;\u7528 spawn \u4e00\u53e5\u8bdd\u5206\u51fa\u4e00\u4e2a\u65b0\u7684\u6267\u884c\u4f53&#xff0c;\u7528 Future \u548c get() \u7b49\u5b83\u8dd1\u5b8c\u3001\u53d6\u56de\u7ed3\u679c\u3002\u5b66\u5b8c\u4f60\u4f1a\u5199\u7b2c\u4e00\u4e2a\\&#8221;\u591a\u7ebf<\/p>\n","protected":false},"author":2,"featured_media":113017,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[70,190,227],"topic":[],"class_list":["post-113018","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-ide","tag-190","tag-227"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/113018.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011\u5e76\u53d1\u57fa\u7840&#xff1a;\u7ebf\u7a0b\u7684\u521b\u5efa\u4e0e\u7b49\u5f85 \u524d\u9762\u7684 25 \u8bfe\u91cc&#xff0c;\u7a0b\u5e8f\u6c38\u8fdc\u662f\u4e00\u6761\u9053\u8d70\u5230\u9ed1&#xff1a;main \u4ece\u7b2c\u4e00\u884c\u6267\u884c\u5230\u6700\u540e\u4e00\u884c&#xff0c;\u4e00\u4ef6\u4e8b\u505a\u5b8c\u624d\u80fd\u505a\u4e0b\u4e00\u4ef6\u3002\u4f46\u771f\u5b9e\u4e16\u754c\u7684\u7a0b\u5e8f\u7ecf\u5e38\u8981&quot;\u540c\u65f6&quot;\u5e72\u51e0\u4ef6\u4e8b\u2014\u2014\u4e0b\u8f7d\u6587\u4ef6\u7684\u540c\u65f6\u5237\u65b0\u8fdb\u5ea6\u6761\u3001\u7b97\u4e00\u6279\u6570\u636e\u7684\u540c\u65f6\u54cd\u5e94\u7528\u6237\u70b9\u51fb\u3002\u672c\u8bfe\u8ba4\u8bc6\u4ed3\u9889\u7684\u7ebf\u7a0b&#xff1a;\u7528 spawn \u4e00\u53e5\u8bdd\u5206\u51fa\u4e00\u4e2a\u65b0\u7684\u6267\u884c\u4f53&#xff0c;\u7528 Future \u548c get() \u7b49\u5b83\u8dd1\u5b8c\u3001\u53d6\u56de\u7ed3\u679c\u3002\u5b66\u5b8c\u4f60\u4f1a\u5199\u7b2c\u4e00\u4e2a&quot;\u591a\u7ebf\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/113018.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-05T03:49:18+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261005034917-6ac31e3d6f597.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/113018.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/113018.html\",\"name\":\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-05T03:49:18+00:00\",\"dateModified\":\"2026-10-05T03:49:18+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/113018.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/113018.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/113018.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/113018.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011\u5e76\u53d1\u57fa\u7840&#xff1a;\u7ebf\u7a0b\u7684\u521b\u5efa\u4e0e\u7b49\u5f85 \u524d\u9762\u7684 25 \u8bfe\u91cc&#xff0c;\u7a0b\u5e8f\u6c38\u8fdc\u662f\u4e00\u6761\u9053\u8d70\u5230\u9ed1&#xff1a;main \u4ece\u7b2c\u4e00\u884c\u6267\u884c\u5230\u6700\u540e\u4e00\u884c&#xff0c;\u4e00\u4ef6\u4e8b\u505a\u5b8c\u624d\u80fd\u505a\u4e0b\u4e00\u4ef6\u3002\u4f46\u771f\u5b9e\u4e16\u754c\u7684\u7a0b\u5e8f\u7ecf\u5e38\u8981\"\u540c\u65f6\"\u5e72\u51e0\u4ef6\u4e8b\u2014\u2014\u4e0b\u8f7d\u6587\u4ef6\u7684\u540c\u65f6\u5237\u65b0\u8fdb\u5ea6\u6761\u3001\u7b97\u4e00\u6279\u6570\u636e\u7684\u540c\u65f6\u54cd\u5e94\u7528\u6237\u70b9\u51fb\u3002\u672c\u8bfe\u8ba4\u8bc6\u4ed3\u9889\u7684\u7ebf\u7a0b&#xff1a;\u7528 spawn \u4e00\u53e5\u8bdd\u5206\u51fa\u4e00\u4e2a\u65b0\u7684\u6267\u884c\u4f53&#xff0c;\u7528 Future \u548c get() \u7b49\u5b83\u8dd1\u5b8c\u3001\u53d6\u56de\u7ed3\u679c\u3002\u5b66\u5b8c\u4f60\u4f1a\u5199\u7b2c\u4e00\u4e2a\"\u591a\u7ebf","og_url":"https:\/\/www.wsisp.com\/helps\/113018.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-05T03:49:18+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261005034917-6ac31e3d6f597.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"6 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/113018.html","url":"https:\/\/www.wsisp.com\/helps\/113018.html","name":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-05T03:49:18+00:00","dateModified":"2026-10-05T03:49:18+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/113018.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/113018.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/113018.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u4ed3\u9889\u8bed\u8a00\u5165\u95e8 \u00b7 \u7b2c26\u8bfe\u3011"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/113018","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=113018"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/113018\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/113017"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=113018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=113018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=113018"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=113018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}