{"id":10006396,"date":"2022-09-05T13:14:27","date_gmt":"2022-09-05T05:14:27","guid":{"rendered":"https:\/\/ityet.com\/?p=10006396"},"modified":"2022-09-05T13:14:27","modified_gmt":"2022-09-05T05:14:27","slug":"%e6%b2%a1%e6%9c%89%e4%ba%8c%e5%8d%81%e5%b9%b4%e5%8a%9f%e5%8a%9b%ef%bc%8c%e5%86%99%e4%b8%8d%e5%87%bathread-sleep0%e8%bf%99%e4%b8%80%e8%a1%8c%e7%9c%8b%e4%bc%bc%e6%97%a0%e7%94%a8","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10006396","title":{"rendered":"\u6ca1\u6709\u4e8c\u5341\u5e74\u529f\u529b\uff0c\u5199\u4e0d\u51faThread.sleep(0)\u8fd9\u4e00\u884c\u201c\u770b\u4f3c\u65e0\u7528\u201d\u7684\u4ee3\u7801\uff01"},"content":{"rendered":"<p>\u4f60\u597d\u5440\uff0c\u6211\u662f\u559c\u63d0\u4e03\u5929\u5c45\u5bb6\u9694\u79bb\u7684\u6b6a\u6b6a\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u8981\u4ece\u4e00\u4e2a\u5947\u602a\u7684\u6ce8\u91ca\u8bf4\u8d77\uff0c\u5c31\u662f\u4e0b\u9762\u8fd9\u5f20\u56fe\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432591\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u4e0d\u7528\u7ba1\u5177\u4f53\u7684\u4ee3\u7801\u903b\u8f91\uff0c\u53ea\u662f\u5355\u5355\u770b\u8fd9\u4e2a for \u5faa\u73af\u3002<\/p>\n<p>\u5728\u5faa\u73af\u91cc\u9762\uff0c\u4e13\u95e8\u6709\u4e2a\u53d8\u91cf j\uff0c\u6765\u8bb0\u5f55\u5f53\u524d\u5faa\u73af\u6b21\u6570\u3002<\/p>\n<p>\u7b2c\u4e00\u6b21\u5faa\u73af\u4ee5\u53ca\u5f80\u540e\u6bcf 1000 \u6b21\u5faa\u73af\u4e4b\u540e\uff0c\u8fdb\u5165\u4e00\u4e2a if \u903b\u8f91\u3002<\/p>\n<p>\u5728\u8fd9\u4e2a if \u903b\u8f91\u4e4b\u4e0a\uff0c\u6807\u6ce8\u4e86\u4e00\u4e2a\u6ce8\u91ca\uff1aprevent gc.<\/p>\n<p>prevent\uff0c\u8fd9\u4e2a\u5355\u8bcd\u5982\u679c\u4e0d\u8ba4\u8bc6\u7684\u540c\u5b66\u8bb0\u4e00\u4e0b\uff0c\u8003\u8bd5\u80af\u5b9a\u8981\u8003\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432592\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u6ce8\u91ca\u7ffb\u8bd1\u4e00\u4e0b\u5c31\u662f\uff1a\u9632\u6b62 GC \u7ebf\u7a0b\u8fdb\u884c\u5783\u573e\u56de\u6536\u3002<\/p>\n<p>\u5177\u4f53\u7684\u5b9e\u73b0\u903b\u8f91\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432593\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6838\u5fc3\u903b\u8f91\u5176\u5b9e\u5c31\u662f\u8fd9\u6837\u4e00\u884c\u4ee3\u7801\uff1a<\/p>\n<blockquote><p>Thread.sleep(0);<\/p><\/blockquote>\n<p>\u8fd9\u6837\u5c31\u80fd\u5b9e\u73b0 prevent gc \u4e86\uff1f<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432594\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u61f5\u903c\u5417\uff1f<\/p>\n<p>\u61f5\u903c\u5c31\u5bf9\u4e86\uff0c\u61f5\u903c\u5c31\u8bf4\u660e\u503c\u5f97\u628a\u73a9\u628a\u73a9\u3002<\/p>\n<p>\u8fd9\u4e2a\u4ee3\u7801\u7247\u6bb5\uff0c\u5176\u5b9e\u662f\u51fa\u81ea RocketMQ \u7684\u6e90\u7801\uff1a<\/p>\n<blockquote><p>org.apache.rocketmq.store.logfile.DefaultMappedFile#warmMappedFile<\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432595\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e8b\u5148\u9700\u8981\u8bf4\u660e\u7684\u662f\uff0c\u6211\u5e76\u6ca1\u6709\u627e\u5230\u5199\u8fd9\u4e2a\u4ee3\u7801\u7684\u4eba\u95ee\u4ed6\u7684\u610f\u56fe\u662f\u4ec0\u4e48\uff0c\u6240\u4ee5\u6211\u53ea\u6709\u57fa\u4e8e\u81ea\u5df1\u7684\u7406\u89e3\u53bb\u63a8\u6d4b\u4ed6\u7684\u610f\u56fe\u3002\u5982\u679c\u63a8\u6d4b\u7684\u4e0d\u5bf9\uff0c\u8fd8\u8bf7\u591a\u591a\u6307\u6559\u3002<\/p>\n<p>\u867d\u7136\u8fd9\u662f RocketMQ \u7684\u6e90\u7801\uff0c\u4f46\u662f\u57fa\u4e8e\u6211\u7684\u7406\u89e3\uff0c\u8fd9\u4e2a\u5c0f\u6280\u5de7\u548c RocketMQ \u6846\u67b6\u6ca1\u6709\u4efb\u4f55\u5173\u7cfb\uff0c\u5b8c\u5168\u53ef\u4ee5\u8131\u79bb\u4e8e\u6846\u67b6\u5b58\u5728\u3002<\/p>\n<p>\u6211\u7ed9\u51fa\u7684\u4fee\u6539\u610f\u89c1\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432596\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u628a int \u4fee\u6539\u4e3a long\uff0c\u7136\u540e\u5c31\u53ef\u4ee5\u76f4\u63a5\u628a for \u5faa\u73af\u91cc\u9762\u7684 if \u903b\u8f91\u5220\u9664\u6389\u4e86\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432597\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u6837\u4e00\u770b\u662f\u4e0d\u662f\u66f4\u52a0\u61f5\u903c\u4e86\uff1f<\/p>\n<p>\u4e0d\u8981\u614c\uff0c\u63a5\u4e0b\u6765\uff0c\u6211\u7ed9\u4f60\u62bd\u4e1d\u5265\u4e2a\u8327\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u5728\u201c\u5265\u8327\u201d\u4e4b\u524d\uff0c\u6211\u5148\u8bf4\u4e00\u4e0b\u7ed3\u8bba\uff1a<\/p>\n<ul>\n<li>\u63d0\u51fa\u8fd9\u4e2a\u4fee\u6539\u65b9\u6848\u7684\u7406\u8bba\u7acb\u8db3\u70b9\u662f Java \u7684\u5b89\u5168\u70b9\u76f8\u5173\u7684\u77e5\u8bc6\uff0c\u4e5f\u5c31\u662f safepoint\u3002<\/li>\n<li>\u5b98\u65b9\u6700\u540e\u6ca1\u6709\u91c7\u7eb3\u8fd9\u4e2a\u4fee\u6539\u65b9\u6848\u3002<\/li>\n<li>\u5b98\u65b9\u91c7\u6ca1\u91c7\u7eb3\u4e0d\u91cd\u8981\uff0c\u91cd\u8981\u7684\u662f\u6211\u9ad8\u4f4e\u5f97\u7ed9\u4f60\u201c\u5265\u4e2a\u8327\u201d\u3002<\/li>\n<\/ul>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432598\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<h2>\u63a2\u7d22<\/h2>\n<p>\u5f53\u6211\u77e5\u9053\u8fd9\u4e2a\u4ee3\u7801\u7247\u6bb5\u662f\u5c5e\u4e8e RocketMQ \u7684\u65f6\u5019\uff0c\u6211\u60f3\u5230\u7684\u7b2c\u4e00\u4e2a\u70b9\u5c31\u662f\u4ece\u4ee3\u7801\u63d0\u4ea4\u8bb0\u5f55\u4e2d\u5bfb\u627e\u7b54\u6848\u3002<\/p>\n<p>\u770b\u63d0\u4ea4\u8005\u662f\u5426\u5728\u63d0\u4ea4\u4ee3\u7801\u7684\u65f6\u5019\u8bf4\u660e\u4e86\u81ea\u5df1\u7684\u610f\u56fe\u3002<\/p>\n<p>\u4e8e\u662f\u6211\u628a\u4ee3\u7801\u62c9\u4e86\u4e0b\u6765\uff0c\u4e00\u770b\u63d0\u4ea4\u8bb0\u5f55\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432599\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u5c31\u77e5\u9053\u8fd9\u91cc\u4e0d\u4f1a\u6709\u7b54\u6848\u4e86\u3002<\/p>\n<p>\u56e0\u4e3a\u8fd9\u4e2a\u7c7b\u7b2c\u4e00\u6b21\u63d0\u4ea4\u7684\u65f6\u5019\u5c31\u5df2\u7ecf\u5305\u542b\u4e86\u8fd9\u4e2a\u903b\u8f91\uff0c\u800c\u4e14\u5bf9\u5e94\u8fd9\u6b21\u63d0\u4ea4\u7684\u4ee3\u7801\u4e5f\u975e\u5e38\u591a\uff0c\u5e76\u6ca1\u6709\u7279\u522b\u8bf4\u660e\u5bf9\u5e94\u7684\u529f\u80fd\u3002<\/p>\n<p>\u4ece\u63d0\u4ea4\u8bb0\u5f55\u4e0a\u6ca1\u6709\u83b7\u5f97\u4ec0\u4e48\u6709\u7528\u7684\u4fe1\u606f\u3002<\/p>\n<p>\u4e8e\u662f\u6211\u628a\u76ee\u5149\u8f6c\u5411\u4e86 github \u7684 issue\uff0c\u62ff\u7740\u5173\u952e\u8bcd prevent gc \u641c\u7d22\u4e86\u4e00\u756a\u3002<\/p>\n<p>\u9664\u4e86\u7b2c\u4e00\u4e2a\u94fe\u63a5\u4e4b\u5916\uff0c\u6ca1\u6709\u627e\u5230\u4ec0\u4e48\u6709\u7528\u7684\u4fe1\u606f\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432600\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u800c\u7b2c\u4e00\u4e2a\u94fe\u63a5\u5bf9\u5e94\u7684 issues \u662f\u8fd9\u4e2a\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/github.com\/apache\/rocketmq\/issues\/4902\">https:\/\/github.com\/apache\/roc&#8230;<\/a><\/p><\/blockquote>\n<p>\u8fd9\u4e2a issues \u5176\u5b9e\u5c31\u662f\u6211\u4eec\u5728\u8ba8\u8bba\u8fd9\u4e2a\u95ee\u9898\u7684\u8fc7\u7a0b\u4e2d\u63d0\u51fa\u6765\u7684\uff0c\u4e5f\u5c31\u662f\u524d\u9762\u51fa\u73b0\u7684\u4fee\u6539\u65b9\u6848\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432601\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u6211\u60f3\u901a\u8fc7\u6e90\u7801\u6216\u8005 github \u627e\u5230\u8fd9\u4e2a\u95ee\u9898\u6743\u5a01\u7684\u56de\u7b54\uff0c\u662f\u627e\u4e0d\u5230\u4e86\u3002<\/p>\n<p>\u4e8e\u662f\u6211\u53c8\u53bb\u4e86\u8fd9\u4e2a\u795e\u5947\u7684\u7f51\u7ad9\uff0c\u5728\u91cc\u9762\u627e\u5230\u4e86\u8fd9\u4e2a 2018 \u5e74\u63d0\u51fa\u7684\u95ee\u9898\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/stackoverflow.com\/questions\/53284031\/why-thread-sleep0-can-prevent-gc-in-rocketmq\">https:\/\/stackoverflow.com\/que&#8230;<\/a><\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432602\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u95ee\u9898\u548c\u6211\u4eec\u7684\u95ee\u9898\u4e00\u6a21\u4e00\u6837\uff0c\u4f46\u662f\u8fd9\u4e2a\u95ee\u9898\u4e0b\u9762\u5c31\u8fd9\u4e00\u4e2a\u56de\u7b54\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432603\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u56de\u7b54\u5e76\u4e0d\u597d\uff0c\u56e0\u4e3a\u6211\u89c9\u5f97\u6ca1\u7b54\u5230\u70b9\u4e0a\uff0c\u4f46\u662f\u6ca1\u5173\u7cfb\uff0c\u6211\u521a\u597d\u53ef\u4ee5\u628a\u8fd9\u4e2a\u56de\u7b54\u4f5c\u4e3a\u6293\u624b\uff0c\u628a\u5dee\u7684\u8fd9\u4e00\u70b9\u62c9\u901a\u5bf9\u9f50\u4e00\u4e0b\uff0c\u7ed9\u5b83\u8d4b\u80fd\u3002<\/p>\n<p>\u5148\u770b\u8fd9\u4e2a\u56de\u7b54\u7684\u7b2c\u4e00\u53e5\u8bdd\uff1aIt does not\uff08\u5b83\u6ca1\u6709\uff09\u3002<\/p>\n<p>\u95ee\u9898\u5c31\u6765\u4e86\uff1a\u201c\u5b83\u201d\u662f\u8c01\uff1f\u201c\u6ca1\u6709\u201d\u4ec0\u4e48\uff1f<\/p>\n<p>\u201c\u5b83\u201d\uff0c\u6307\u7684\u5c31\u662f\u6211\u4eec\u524d\u9762\u51fa\u73b0\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u201c\u6ca1\u6709\u201d\uff0c\u662f\u8bf4\u6ca1\u6709\u9632\u6b62 GC \u7ebf\u7a0b\u8fdb\u884c\u5783\u573e\u56de\u6536\u3002<\/p>\n<p>\u8fd9\u4e2a\u7684\u56de\u7b54\u8bf4\uff1a\u901a\u8fc7\u8c03\u7528 Thread.sleep(0) \u7684\u76ee\u7684\u662f\u4e3a\u4e86\u8ba9 GC \u7ebf\u7a0b\u6709\u673a\u4f1a\u88ab\u64cd\u4f5c\u7cfb\u7edf\u9009\u4e2d\uff0c\u4ece\u800c\u8fdb\u884c\u5783\u573e\u6e05\u7406\u7684\u5de5\u4f5c\u3002\u5b83\u7684\u526f\u4f5c\u7528\u662f\uff0c\u53ef\u80fd\u4f1a\u66f4\u9891\u7e41\u5730\u8fd0\u884c GC\uff0c\u6bd5\u7adf\u4f60\u6bcf 1000 \u6b21\u8fed\u4ee3\u5c31\u6709\u4e00\u6b21\u8fd0\u884c GC \u7684\u673a\u4f1a\uff0c\u4f46\u662f\u597d\u5904\u662f\u53ef\u4ee5\u9632\u6b62\u957f\u65f6\u95f4\u7684\u5783\u573e\u6536\u96c6\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0c\u8fd9\u4e2a\u4ee3\u7801\u662f\u60f3\u8981\u201c\u89e6\u53d1\u201dGC\uff0c\u800c\u4e0d\u662f\u201c\u907f\u514d\u201dGC\uff0c\u6216\u8005\u8bf4\u662f\u201c\u907f\u514d\u201d\u65f6\u95f4\u5f88\u957f\u7684 GC\u3002\u4ece\u8fd9\u4e2a\u89d2\u5ea6\u6765\u8bf4\uff0c\u7a0b\u5e8f\u91cc\u9762\u7684\u6ce8\u91ca\u5176\u5b9e\u662f\u5728\u6492\u8c0e\u6216\u8005\u6ca1\u5199\u5b8c\u6574\u3002<\/p>\n<p>\u4e0d\u662f prevent gc\uff0c\u800c\u662f\u5bf9 gc \u91c7\u53d6\u4e86\u201c\u6253\u6563\u8fd0\u884c\uff0c\u524a\u5cf0\u586b\u8c37\u201d\u7684\u601d\u60f3\uff0c\u4ece\u800c prevent long time gc\u3002<\/p>\n<p>\u4f46\u662f\u4f60\u60f3\u60f3\uff0c\u6211\u4eec\u81ea\u5df1\u7f16\u7a0b\u7684\u65f6\u5019\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\u4ece\u6765\u4e5f\u6ca1\u5192\u51fa\u8fc7\u201c\u8fd9\u4e2a\u5730\u65b9\u5e94\u8be5\u89e6\u53d1\u4e00\u4e0b GC\u201d\u8fd9\u6837\u60f3\u6cd5\u5427\uff1f<\/p>\n<p>\u56e0\u4e3a\u6211\u4eec\u77e5\u9053\uff0cJava \u7a0b\u5e8f\u5458\u6765\u8bf4\uff0c\u865a\u62df\u673a\u6709\u81ea\u5df1\u7684 GC \u673a\u5236\uff0c\u6211\u4eec\u4e0d\u9700\u8981\u50cf\u5199 C \u6216\u8005 C++ \u90a3\u6837\u5f97\u81ea\u5df1\u7ba1\u7406\u5185\u5b58\uff0c\u53ea\u8981\u5173\u6ce8\u4e8e\u4e1a\u52a1\u4ee3\u7801\u5373\u53ef\uff0c\u5e76\u6ca1\u6709\u7279\u522b\u6ce8\u610f GC \u673a\u5236\u3002<\/p>\n<p>\u90a3\u4e48\u672c\u6587\u4e2d\u6700\u5173\u952e\u7684\u4e00\u4e2a\u95ee\u9898\u5c31\u6765\u4e86\uff1a<strong>\u4e3a\u4ec0\u4e48\u8fd9\u91cc\u8981\u5728\u4ee3\u7801\u91cc\u9762\u7279\u522b\u6ce8\u610f GC\uff0c\u60f3\u8981\u5c1d\u8bd5\u201c\u89e6\u53d1\u201dGC \u5462\uff1f<\/strong><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432604\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5148\u8bf4\u7b54\u6848\uff1asafepoint\uff0c\u5b89\u5168\u70b9\u3002<\/p>\n<p>\u5173\u4e8e\u5b89\u5168\u70b9\u7684\u63cf\u8ff0\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u770b\u300a\u6df1\u5165\u7406\u89e3JVM\u865a\u62df\u673a(\u7b2c\u4e09\u7248)\u300b\u7684 3.4.2 \u5c0f\u8282\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432605\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6ce8\u610f\u4e66\u91cc\u9762\u7684\u63cf\u8ff0\uff1a<\/p>\n<blockquote><p>\u6709\u4e86\u5b89\u5168\u70b9\u7684\u8bbe\u5b9a\uff0c\u4e5f\u5c31\u51b3\u5b9a\u4e86\u7528\u6237\u7a0b\u5e8f\u6267\u884c\u65f6\u5e76\u975e\u5728\u4ee3\u7801\u6307\u4ee4\u6d41\u7684\u4efb\u610f\u4f4d\u7f6e\u90fd\u80fd\u591f\u505c\u987f\u4e0b\u6765\u5f00\u59cb\u5783\u573e\u6536\u96c6\uff0c\u800c\u662f\u5f3a\u5236\u8981\u6c42\u5fc5\u987b\u6267\u884c\u5230\u8fbe\u5b89\u5168\u70b9\u540e\u624d\u80fd\u591f\u6682\u505c\u3002<\/p><\/blockquote>\n<p>\u6362\u8a00\u4e4b\uff1a\u6ca1\u6709\u5230\u5b89\u5168\u70b9\uff0c\u662f\u4e0d\u80fd STW\uff0c\u4ece\u800c\u8fdb\u884c GC \u7684\u3002<\/p>\n<p>\u5982\u679c\u5728\u4f60\u7684\u8ba4\u77e5\u91cc\u9762 GC \u7ebf\u7a0b\u662f\u968f\u65f6\u90fd\u53ef\u4ee5\u8fd0\u884c\u7684\u3002\u90a3\u4e48\u5c31\u9700\u8981\u5237\u65b0\u4e00\u4e0b\u8ba4\u77e5\u4e86\u3002<\/p>\n<p>\u63a5\u7740\uff0c\u8ba9\u6211\u4eec\u628a\u76ee\u5149\u653e\u5230\u4e66\u7684 5.2.8 \u5c0f\u8282\uff1a\u7531\u5b89\u5168\u70b9\u5bfc\u81f4\u957f\u65f6\u95f4\u505c\u987f\u3002<\/p>\n<p>\u91cc\u9762\u6709\u8fd9\u6837\u4e00\u6bb5\u8bdd\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432606\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6211\u628a\u5212\u7ebf\u7684\u90e8\u5206\u5355\u72ec\u62ff\u51fa\u6765\uff0c\u4f60\u4ed4\u7ec6\u8bfb\u4e00\u904d\uff1a<\/p>\n<blockquote><p>\u662fHotSpot\u865a\u62df\u673a\u4e3a\u4e86\u907f\u514d\u5b89\u5168\u70b9\u8fc7\u591a\u5e26\u6765\u8fc7\u91cd\u7684\u8d1f\u62c5\uff0c\u5bf9\u5faa\u73af\u8fd8\u6709\u4e00\u9879\u4f18\u5316\u63aa\u65bd\uff0c\u8ba4\u4e3a\u5faa\u73af\u6b21\u6570\u8f83\u5c11\u7684\u8bdd\uff0c\u6267\u884c\u65f6\u95f4\u5e94\u8be5\u4e5f\u4e0d\u4f1a\u592a\u957f\uff0c\u6240\u4ee5\u4f7f\u7528int\u7c7b\u578b\u6216\u8303\u56f4\u66f4\u5c0f\u7684\u6570\u636e\u7c7b\u578b\u4f5c\u4e3a\u7d22\u5f15\u503c\u7684\u5faa\u73af\u9ed8\u8ba4\u662f\u4e0d\u4f1a\u88ab\u653e\u7f6e\u5b89\u5168\u70b9\u7684\u3002\u8fd9\u79cd\u5faa\u73af\u88ab\u79f0\u4e3a\u53ef\u6570\u5faa\u73af\uff08Counted Loop\uff09\uff0c\u76f8\u5bf9\u5e94\u5730\uff0c\u4f7f\u7528long\u6216\u8005\u8303\u56f4\u66f4\u5927\u7684\u6570\u636e\u7c7b\u578b\u4f5c\u4e3a\u7d22\u5f15\u503c\u7684\u5faa\u73af\u5c31\u88ab\u79f0\u4e3a\u4e0d\u53ef\u6570\u5faa\u73af\uff08Uncounted Loop\uff09\uff0c\u5c06\u4f1a\u88ab\u653e\u7f6e\u5b89\u5168\u70b9\u3002<\/p><\/blockquote>\n<p>\u610f\u601d\u5c31\u662f\u5728\u53ef\u6570\u5faa\u73af\uff08Counted Loop\uff09\u7684\u60c5\u51b5\u4e0b\uff0cHotSpot \u865a\u62df\u673a\u641e\u4e86\u4e00\u4e2a\u4f18\u5316\uff0c\u5c31\u662f\u7b49\u5faa\u73af\u7ed3\u675f\u4e4b\u540e\uff0c\u7ebf\u7a0b\u624d\u4f1a\u8fdb\u5165\u5b89\u5168\u70b9\u3002<\/p>\n<p>\u53cd\u8fc7\u6765\u8bf4\u5c31\u662f\uff1a\u5faa\u73af\u5982\u679c\u6ca1\u6709\u7ed3\u675f\uff0c\u7ebf\u7a0b\u4e0d\u4f1a\u8fdb\u5165\u5b89\u5168\u70b9\uff0cGC \u7ebf\u7a0b\u5c31\u5f97\u7b49\u7740\u5f53\u524d\u7684\u7ebf\u7a0b\u5faa\u73af\u7ed3\u675f\uff0c\u8fdb\u5165\u5b89\u5168\u70b9\uff0c\u624d\u80fd\u5f00\u59cb\u5de5\u4f5c\u3002<\/p>\n<p>\u4ec0\u4e48\u662f\u53ef\u6570\u5faa\u73af\uff08Counted Loop\uff09\uff1f<\/p>\n<p>\u4e66\u91cc\u9762\u7684\u8fd9\u4e2a\u6848\u4f8b\u6765\u81ea\u4e8e\u8fd9\u4e2a\u94fe\u63a5\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/juejin.cn\/post\/6844903878765314061\">https:\/\/juejin.cn\/post\/684490&#8230;<\/a><br \/>HBase\u5b9e\u6218\uff1a\u8bb0\u4e00\u6b21Safepoint\u5bfc\u81f4\u957f\u65f6\u95f4STW\u7684\u8e29\u5751\u4e4b\u65c5<\/p><\/blockquote>\n<p>\u5982\u679c\u4f60\u6709\u65f6\u95f4\uff0c\u6211\u5efa\u8bae\u4f60\u628a\u8fd9\u4e2a\u6848\u4f8b\u5b8c\u6574\u7684\u770b\u4e00\u4e0b\uff0c\u6211\u53ea\u622a\u53d6\u95ee\u9898\u89e3\u51b3\u7684\u90e8\u5206\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432607\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u622a\u56fe\u4e2d\u7684 while(i &lt; end) \u5c31\u662f\u4e00\u4e2a\u53ef\u6570\u5faa\u73af\uff0c\u7531\u4e8e\u6267\u884c\u8fd9\u4e2a\u5faa\u73af\u7684\u7ebf\u7a0b\u9700\u8981\u5728\u5faa\u73af\u7ed3\u675f\u540e\u624d\u8fdb\u5165 Safepoint\uff0c\u6240\u4ee5\u5148\u8fdb\u5165 Safepoint \u7684\u7ebf\u7a0b\u9700\u8981\u7b49\u5f85\u5b83\u3002\u4ece\u800c\u5f71\u54cd\u5230 GC \u7ebf\u7a0b\u7684\u8fd0\u884c\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u4fee\u6539\u65b9\u6848\u5c31\u662f\u628a int \u4fee\u6539\u4e3a long\u3002<\/p>\n<p>\u539f\u7406\u5c31\u662f\u8ba9\u5176\u53d8\u4e3a\u4e0d\u53ef\u6570\u5faa\u73af\uff08Uncounted Loop\uff09\uff0c\u4ece\u800c\u4e0d\u7528\u7b49\u5faa\u73af\u7ed3\u675f\uff0c\u5728\u5faa\u73af\u671f\u95f4\u5c31\u80fd\u8fdb\u5165 Safepoint\u3002<\/p>\n<p>\u63a5\u7740\u6211\u4eec\u518d\u628a\u76ee\u5149\u62c9\u56de\u5230\u8fd9\u91cc\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432608\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u5faa\u73af\u4e5f\u662f\u4e00\u4e2a\u53ef\u6570\u5faa\u73af\u3002<\/p>\n<p>Thread.sleep(0) \u8fd9\u4e2a\u4ee3\u7801\u770b\u8d77\u6765\u83ab\u540d\u5176\u5999\uff0c\u4f46\u662f\u6211\u662f\u4e0d\u662f\u53ef\u4ee5\u5927\u80c6\u7684\u731c\u6d4b\u4e00\u4e0b\uff1a\u6545\u610f\u5199\u8fd9\u4e2a\u4ee3\u7801\u7684\u4eba\uff0c\u662f\u4e0d\u662f\u4e3a\u4e86\u5728\u8fd9\u91cc\u653e\u7f6e\u4e00\u4e2a Safepoint \u5462\uff0c\u4ee5\u8fbe\u5230\u907f\u514d GC \u7ebf\u7a0b\u957f\u65f6\u95f4\u7b49\u5f85\uff0c\u4ece\u800c\u52a0\u957f stop the world \u7684\u65f6\u95f4\u7684\u76ee\u7684\uff1f<\/p>\n<p>\u6240\u4ee5\uff0c\u6211\u63a5\u4e0b\u6765\u53ea\u9700\u8981\u627e\u5230 sleep \u4f1a\u8fdb\u5165 Safepoint \u7684\u8bc1\u636e\uff0c\u5c31\u80fd\u8bc1\u660e\u6211\u7684\u731c\u60f3\u3002<\/p>\n<p>\u4f60\u731c\u600e\u4e48\u7740\uff1f<\/p>\n<p>\u672c\u6765\u662f\u60f3\u53bb\u770b\u4e00\u4e0b\u6e90\u7801\uff0c\u7ed3\u679c\u556a\u7684\u4e00\u4e0b\uff0c\u5728\u6e90\u7801\u7684\u6ce8\u91ca\u91cc\u9762\uff0c\u76f4\u63a5\u627e\u5230\u4e86\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/hg.openjdk.java.net\/jdk8u\/jdk8u\/hotspot\/file\/tip\/src\/share\/vm\/runtime\/safepoint.cpp\">https:\/\/hg.openjdk.java.net\/j&#8230;<\/a><\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432609\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6ce8\u91ca\u91cc\u9762\u8bf4\uff0c\u5728\u7a0b\u5e8f\u8fdb\u5165 Safepoint \u7684\u65f6\u5019\uff0c Java \u7ebf\u7a0b\u53ef\u80fd\u6b63\u5904\u4e8e\u6846\u8d77\u6765\u7684\u4e94\u79cd\u4e0d\u540c\u7684\u72b6\u6001\uff0c\u9488\u5bf9\u4e0d\u540c\u7684\u72b6\u6001\u6709\u4e0d\u540c\u7684\u5904\u7406\u65b9\u6848\u3002<\/p>\n<p>\u672c\u6765\u6211\u60f3\u4e00\u4e2a\u4e2a\u7684\u7ffb\u8bd1\u7684\uff0c\u4f46\u662f\u4fe1\u606f\u91cf\u592a\u5927\uff0c\u6211\u6d88\u5316\u8d77\u6765\u6709\u70b9\u8d39\u52b2\u513f\uff0c\u6240\u4ee5\u5c31\u4e0d\u4e71\u8bf4\u4e86\u3002<\/p>\n<p>\u4e3b\u8981\u805a\u7126\u4e8e\u548c\u672c\u6587\u76f8\u5173\u7684\u7b2c\u4e8c\u70b9\uff1aRunning in native code\u3002<\/p>\n<blockquote><p>When returning from the native code, a Java thread must check the safepoint _state to see if we must block.<\/p><\/blockquote>\n<p>\u7b2c\u4e00\u53e5\u8bdd\uff0c\u5c31\u662f\u7b54\u6848\uff0c\u610f\u601d\u5c31\u662f\u4e00\u4e2a\u7ebf\u7a0b\u5728\u8fd0\u884c native \u65b9\u6cd5\u540e\uff0c\u8fd4\u56de\u5230 Java \u7ebf\u7a0b\u540e\uff0c\u5fc5\u987b\u8fdb\u884c\u4e00\u6b21 safepoint \u7684\u68c0\u6d4b\u3002<\/p>\n<p>\u540c\u65f6\u6211\u5728\u77e5\u4e4e\u770b\u5230\u4e86 R \u5927\u7684\u8fd9\u4e2a\u56de\u7b54\uff0c\u91cc\u9762\u6709\u8fd9\u6837\u4e00\u53e5\uff0c\u4e5f\u5370\u8bc1\u4e86\u8fd9\u4e2a\u70b9\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/www.zhihu.com\/question\/29268019\/answer\/43762165\">https:\/\/www.zhihu.com\/questio&#8230;<\/a><\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432610\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u90a3\u4e48\u63a5\u4e0b\u6765\uff0c\u5c31\u662f\u89c1\u8bc1\u5947\u8ff9\u7684\u65f6\u523b\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432611\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6839\u636e R \u5927\u7684\u8bf4\u6cd5\uff1a\u6b63\u5728\u6267\u884c native \u51fd\u6570\u7684\u7ebf\u7a0b\u770b\u4f5c\u201c\u5df2\u7ecf\u8fdb\u5165\u4e86safepoint\u201d\uff0c\u6216\u8005\u628a\u8fd9\u79cd\u60c5\u51b5\u53eb\u505a\u201c\u5728safe-region\u91cc\u201d\u3002<\/p>\n<p>sleep \u65b9\u6cd5\u5c31\u662f\u4e00\u4e2a native \u65b9\u6cd5\uff0c\u4f60\u8bf4\u5de7\u4e0d\u5de7\uff1f<\/p>\n<p>\u6240\u4ee5\uff0c\u5230\u8fd9\u91cc\u6211\u4eec\u53ef\u4ee5\u786e\u5b9a\u7684\u662f\uff1a\u8c03\u7528 sleep \u65b9\u6cd5\u7684\u7ebf\u7a0b\u4f1a\u8fdb\u5165 Safepoint\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u6211\u8fd8\u627e\u5230\u4e86\u4e00\u4e2a 2013 \u5e74\u7684 R \u5927\u5173\u4e8e\u7c7b\u4f3c\u95ee\u9898\u8ba8\u8bba\u7684\u5e16\u5b50\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/hllvm-group.iteye.com\/group\/topic\/38232?page=2\">https:\/\/hllvm-group.iteye.com&#8230;<\/a><\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432612\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u91cc\u5c31\u76f4\u63a5\u70b9\u540d\u9053\u59d3\u7684\u6307\u51fa\u4e86\uff1aThread.sleep(0).<\/p>\n<p>\u8fd9\u8ba9\u6211\u60f3\u8d77\u4ee5\u524d\u6709\u4e2a\u9762\u8bd5\u9898\u95ee\uff1aThread.sleep(0) \u6709\u4ec0\u4e48\u7528\u3002<\/p>\n<p>\u5f53\u65f6\u6211\u5c31\u60f3\uff1a\u8fd9\u9898\u771f\u96be\uff08S\uff09\u554a\uff08B\uff09\u3002\u73b0\u5728\u53d1\u73b0\u539f\u6765\u662f\u6211\u9053\u884c\u4e0d\u591f\uff0c\u5c0f\u4e11\u7adf\u662f\u6211\u81ea\u5df1\u3002<\/p>\n<p>\u8fd8\u771f\u7684\u662f\u6709\u7528\u3002<\/p>\n<h2>\u5b9e\u8df5<\/h2>\n<p>\u524d\u9762\u5176\u5b9e\u8bf4\u7684\u90fd\u662f\u7406\u8bba\u3002<\/p>\n<p>\u8fd9\u4e00\u90e8\u5206\u6211\u4eec\u6765\u62ff\u4ee3\u7801\u5b9e\u8df5\u8dd1\u4e0a\u4e00\u628a\uff0c\u5c31\u62ff\u6211\u4e4b\u524d\u5206\u4eab\u8fc7\u7684<a href=\"https:\/\/mp.weixin.qq.com\/s\/KDUccdLALWdjNBrFjVR74Q\">\u300a\u771f\u662f\u7edd\u4e86\uff01\u8fd9\u6bb5\u88abJVM\u52a8\u4e86\u624b\u811a\u7684\u4ee3\u7801\uff01\u300b<\/a>\u6587\u7ae0\u91cc\u9762\u7684\u6848\u4f8b\u3002<\/p>\n<pre><code>public class MainTest {\n\n    public static AtomicInteger num = new AtomicInteger(0);\n\n    public static void main(String[] args) throws InterruptedException {\n        Runnable runnable=()-&gt;{\n            for (int i = 0; i &lt; 1000000000; i++) {\n                num.getAndAdd(1);\n            }\n            System.out.println(Thread.currentThread().getName()+&quot;\u6267\u884c\u7ed3\u675f!&quot;);\n        };\n\n        Thread t1 = new Thread(runnable);\n        Thread t2 = new Thread(runnable);\n        t1.start();\n        t2.start();\n        Thread.sleep(1000);\n        System.out.println(&quot;num = &quot; + num);\n    }\n}<\/code><\/pre>\n<p>\u8fd9\u4e2a\u4ee3\u7801\uff0c\u4f60\u76f4\u63a5\u7c98\u5230\u4f60\u7684 idea \u91cc\u9762\u53bb\u5c31\u80fd\u8dd1\u3002<\/p>\n<p>\u6309\u7167\u4ee3\u7801\u6765\u770b\uff0c\u4e3b\u7ebf\u7a0b\u4f11\u7720 1000ms \u540e\u5c31\u4f1a\u8f93\u51fa\u7ed3\u679c\uff0c\u4f46\u662f\u5b9e\u9645\u60c5\u51b5\u5374\u662f\u4e3b\u7ebf\u7a0b\u4e00\u76f4\u5728\u7b49\u5f85 t1,t2 \u6267\u884c\u7ed3\u675f\u624d\u7ee7\u7eed\u6267\u884c\u3002<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432613\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u5faa\u73af\u5c31\u5c5e\u4e8e\u524d\u9762\u8bf4\u7684\u53ef\u6570\u5faa\u73af\uff08Counted Loop\uff09\u3002<\/p>\n<p>\u8fd9\u4e2a\u7a0b\u5e8f\u53d1\u751f\u4e86\u4ec0\u4e48\u4e8b\u60c5\u5462\uff1f<\/p>\n<ul>\n<li>1.\u542f\u52a8\u4e86\u4e24\u4e2a\u957f\u7684\u3001\u4e0d\u95f4\u65ad\u7684\u5faa\u73af\uff08\u5185\u90e8\u6ca1\u6709\u5b89\u5168\u70b9\u68c0\u67e5\uff09\u3002<\/li>\n<li>2.\u4e3b\u7ebf\u7a0b\u8fdb\u5165\u7761\u7720\u72b6\u6001 1 \u79d2\u949f\u3002<\/li>\n<li>3.\u57281000 ms\u4e4b\u540e\uff0cJVM\u5c1d\u8bd5\u5728Safepoint\u505c\u6b62\uff0c\u4ee5\u4fbfJava\u7ebf\u7a0b\u8fdb\u884c\u5b9a\u671f\u6e05\u7406\uff0c\u4f46\u662f\u76f4\u5230\u53ef\u6570\u5faa\u73af\u5b8c\u6210\u540e\u624d\u80fd\u6267\u884c\u6b64\u64cd\u4f5c\u3002<\/li>\n<li>4.\u4e3b\u7ebf\u7a0b\u7684 Thread.sleep \u65b9\u6cd5\u4ece native \u8fd4\u56de\uff0c\u53d1\u73b0\u5b89\u5168\u70b9\u64cd\u4f5c\u6b63\u5728\u8fdb\u884c\u4e2d\uff0c\u4e8e\u662f\u628a\u81ea\u5df1\u6302\u8d77\uff0c\u76f4\u5230\u64cd\u4f5c\u7ed3\u675f\u3002<\/li>\n<\/ul>\n<p>\u6240\u4ee5\uff0c\u5f53\u6211\u4eec\u628a int \u4fee\u6539\u4e3a long \u540e\uff0c\u7a0b\u5e8f\u5c31\u8868\u73b0\u6b63\u5e38\u4e86\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432614\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u53d7\u5230 RocketMQ \u6e90\u7801\u7684\u542f\u793a\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u76f4\u63a5\u628a\u5b83\u7684\u4ee3\u7801\u62ff\u8fc7\u6765\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432615\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u6837\uff0c\u5373\u4f7f for \u5faa\u73af\u7684\u5bf9\u8c61\u662f int \u7c7b\u578b\uff0c\u4e5f\u53ef\u4ee5\u6309\u7167\u9884\u671f\u6267\u884c\u3002\u56e0\u4e3a\u6211\u4eec\u76f8\u5f53\u4e8e\u5728\u5faa\u73af\u4f53\u4e2d\u63d2\u5165\u4e86 Safepoint\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u6211\u901a\u8fc7<strong>\u4e0d\u4e25\u8c28\u7684\u65b9\u5f0f<\/strong>\u6d4b\u8bd5\u4e86\u4e00\u4e0b\u4e24\u4e2a\u65b9\u6848\u7684\u8017\u65f6\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432616\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5728\u6211\u7684\u673a\u5668\u4e0a\u8fd0\u884c\u4e86\u51e0\u6b21\uff0c\u65f6\u95f4\u4e0a\u90fd\u5dee\u8ddd\u4e0d\u5927\u3002<\/p>\n<p>\u4f46\u662f\u8981\u8bba\u903c\u683c\u7684\u8bdd\uff0c\u8fd8\u5f97\u662f\u53f3\u8fb9\u7684 prevent gc \u7684\u5199\u6cd5\u3002\u6ca1\u6709\u4e8c\u5341\u5e74\u529f\u529b\uff0c\u5199\u4e0d\u51fa\u8fd9\u4e00\u884c\u201c\u770b\u4f3c\u65e0\u7528\u201d\u7684\u4ee3\u7801\uff01<\/p>\n<h2>\u989d\u5916\u63d0\u4e00\u53e5<\/h2>\n<p>\u518d\u8bf4\u4e00\u4e2a\u4e5f\u662f\u7531\u524d\u9762\u7684 RocketMQ \u7684\u6e90\u7801\u5f15\u8d77\u7684\u4e00\u4e2a\u601d\u8003\uff1a<\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432617\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u8fd9\u4e2a\u65b9\u6cd5\u662f\u5728\u5e72\u5565\uff1f<\/p>\n<p>\u9884\u70ed\u6587\u4ef6\uff0c\u6309\u7167 4K \u7684\u5927\u5c0f\u5f80 byteBuffer \u653e 0\uff0c\u5bf9\u6587\u4ef6\u8fdb\u884c\u9884\u70ed\u3002<\/p>\n<blockquote><p>byteBuffer.put(i, (byte) 0);<\/p><\/blockquote>\n<p>\u4e3a\u4ec0\u4e48\u6211\u4f1a\u5bf9\u8fd9\u4e2a 4k \u7684\u9884\u70ed\u6bd4\u8f83\u654f\u611f\u5462\uff1f<\/p>\n<p>\u53bb\u5e74\u7684\u5929\u6c60\u5927\u8d5b\u6709\u8fd9\u6837\u7684\u4e00\u4e2a\u8d5b\u9053\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/tianchi.aliyun.com\/competition\/entrance\/531922\/information\">https:\/\/tianchi.aliyun.com\/co&#8230;<\/a><\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432618\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u5176\u4e2d\u6709\u4e24\u4e2a\u53c2\u8d5b\u9009\u5927\u4f6c\u90fd\u63d0\u5230\u4e86\u201c\u6587\u4ef6\u9884\u70ed\u201d\u7684\u601d\u8def\u3002<\/p>\n<p>\u6211\u628a\u94fe\u63a5\u653e\u5728\u4e0b\u9762\u4e86\uff0c\u6709\u5174\u8da3\u7684\u53ef\u4ee5\u53bb\u7ec6\u8bfb\u4e00\u4e0b\uff1a<\/p>\n<blockquote><p><a href=\"https:\/\/tianchi.aliyun.com\/forum\/postDetail?spm=5176.12586969.0.0.13714154spKjib&#038;postId=300892\">https:\/\/tianchi.aliyun.com\/fo&#8230;<\/a><\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432619\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432620\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<blockquote><p><a href=\"https:\/\/tianchi.aliyun.com\/forum\/postDetail?spm=5176.21852664.0.0.4c353a5a06PzVZ&#038;postId=313716\">https:\/\/tianchi.aliyun.com\/fo&#8230;<\/a><\/p><\/blockquote>\n<p><img decoding=\"async\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000042432621\" alt=\"\" title=\"\" loading=\"lazy\"><\/p>\n<p>\u6700\u540e\uff0c\u611f\u8c22\u4f60\u9605\u8bfb\u6211\u7684\u6587\u7ae0\u3002\u6b22\u8fce\u5173\u6ce8\u516c\u4f17\u53f7\u3010why\u6280\u672f\u3011\uff0c\u6587\u7ae0\u5168\u7f51\u9996\u53d1\u54e6\u3002<\/p>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000042432589\">https:\/\/segmentfault.com\/a\/1190000042432589<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f60\u597d\u5440\uff0c\u6211\u662f\u559c\u63d0\u4e03\u5929\u5c45\u5bb6\u9694\u79bb\u7684\u6b6a\u6b6a\u3002 \u8fd9\u7bc7\u6587\u7ae0\u8981\u4ece\u4e00\u4e2a\u5947\u602a\u7684\u6ce8\u91ca\u8bf4\u8d77\uff0c\u5c31\u662f\u4e0b\u9762\u8fd9\u5f20\u56fe\uff1a \u6211\u4eec\u53ef\u4ee5\u4e0d\u7528\u7ba1\u5177\u4f53\u7684\u4ee3 [&hellip;]<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[],"tags":[],"class_list":["post-10006396","post","type-post","status-publish","format-standard","hentry"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006396","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10006396"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10006396\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10006396"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10006396"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10006396"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}