{"id":216343,"date":"2020-11-20T18:50:29","date_gmt":"2020-11-20T10:50:29","guid":{"rendered":"http:\/\/4563.org\/?p=216343"},"modified":"2020-11-20T18:50:29","modified_gmt":"2020-11-20T10:50:29","slug":"%e8%af%b7%e6%95%99%e5%90%84%e4%bd%8d%e5%a4%a7%e4%bd%ac%ef%bc%8c-chan-1-%e9%98%bb%e5%a1%9e%e5%92%8c%e9%98%bb%e5%a1%9e%e7%bb%93%e6%9d%9f%e7%9a%84%e6%97%b6%e5%80%99%ef%bc%8c-goroutine-%e5%9c%a8","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=216343","title":{"rendered":"\u8bf7\u6559\u5404\u4f4d\u5927\u4f6c\uff0c chan &lt;- 1 \u963b\u585e\u548c\u963b\u585e\u7ed3\u675f\u7684\u65f6\u5019\uff0c goroutine \u5728\u5e72\u561b\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u8bf7\u6559\u5404\u4f4d\u5927\u4f6c\uff0c chan &lt;- 1 \u963b\u585e\u548c\u963b\u585e\u7ed3\u675f\u7684\u65f6\u5019\uff0c goroutine \u5728\u5e72\u561b\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : koujyungenn <\/span>  <span><i><\/i> 3<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u770b\u4e86 MPG \u6a21\u578b\uff0c\u6709\u4e9b\u7ec6\u8282\u8fd8\u662f\u6ca1\u61c2\u3002<\/p>\n<p>\u5047\u8bbe chan \u662f\u65e0\u7f13\u51b2\u901a\u9053\uff0c\u5047\u8bbe G1 \u5f80 chan \u91cc\u6254\u6570\u636e\u963b\u585e\u4e86\u3002<\/p>\n<p>\u6b64\u65f6\u4f1a\u89e6\u53d1 Go \u7684 HandOff \u673a\u5236\uff0c\u5c06 P1 detach()\u5230\u5176\u4ed6 M \u4e0a\u5417\uff1f<\/p>\n<p>\u5982\u679c\u4f1a\uff0c\u8fc7\u6bb5\u65f6\u95f4\u53e6\u4e00\u4e2a\u534f\u7a0b G2 \u4ece chan \u91cc\u53d6\u6570\u636e\uff0cG1 \u7684\u963b\u585e\u7ed3\u675f\u3002G1 \u4f1a\u76f4\u63a5\u8fdb\u5165\u67d0\u4e2a P \u7684\u534f\u7a0b\u961f\u5217\u5c3e(\u6709\u7a7a\u95f2 P)\u6216\u5168\u5c40\u534f\u7a0b\u961f\u5217\u5c3e(\u65e0\u7a7a\u95f2 P)\u5417\uff1f\u8fd8\u662f\u8bf4\u63d2\u961f\u56de\u5230 P1 \u7684\u961f\u9996\uff1f<\/p>\n<p>\u8fd8\u662f\u8bf4\u4ee5\u4e0a\u90fd\u4e0d\u5bf9\uff0c\u662f\u53e6\u5916\u4e00\u79cd\u505a\u6cd5\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>2<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"4396517\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xiaohanliang <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             (\u6211\u7684\u4e00\u4e9b\u7406\u89e3, \u9519\u4e86\u6b22\u8fce\u6307\u6b63)<\/p>\n<p>Q: \u6b64\u65f6\u4f1a\u89e6\u53d1 Go \u7684 HandOff \u673a\u5236\uff0c\u5c06 P1 detach()\u5230\u5176\u4ed6 M \u4e0a\u5417\uff1f<\/p>\n<p>A: \u4e0d\u4f1a, \u8fd9\u4e2a G \u4f1a\u88ab\u6253\u5305\u6210 sudog, \u7ed1\u5b9a\u5728\u8fd9\u4e2a chan \u7684\u76f8\u5173 sudog \u961f\u5217\u4e0a, \u7b49\u5230\u4e0b\u6b21\u6709\u4eba\u4ece\u8fd9\u4e2a chan \u91cc\u53d6\u6570\u636e, \u5c31\u904d\u5386\u8fd9\u4e2a sudog \u961f\u5217, \u627e\u5230\u8fd9\u4e2a\u6c89\u7761\u7684 sudog, \u628a\u91cc\u9762\u7684 G \u5524\u9192, \u518d\u653e\u5230 P \u4e0a\u53bb\u8fd0\u884c                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"4396518\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : koujyungenn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @xiaohanliang #1 \u55ef&#8230;.sudog\uff0c\u5bf9\u4e8e\u6211\u6765\u8bf4\u662f\u4e2a\u65b0\u4e1c\u897f\uff0c\u5f97\u53bb\u4e86\u89e3\u4e0b\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf7\u6559\u5404\u4f4d\u5927\u4f6c\uff0c chan &lt;&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/216343"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=216343"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/216343\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=216343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=216343"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=216343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}