{"id":65119,"date":"2025-05-03T13:58:39","date_gmt":"2025-05-03T05:58:39","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65119\/"},"modified":"2025-05-03T13:58:39","modified_gmt":"2025-05-03T05:58:39","slug":"%e7%ba%bf%e7%a8%8b%e6%b1%a0%e9%9a%94%e7%a6%bb%ef%bc%9a%e4%b8%ba%e4%bb%80%e4%b9%88%e8%a6%81%e5%88%86%e5%89%b2%e4%bd%a0%e7%9a%84%e7%ba%bf%e7%a8%8b%e6%b1%a0%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65119\/","title":{"rendered":"\u7ebf\u7a0b\u6c60\u9694\u79bb\uff1a\u4e3a\u4ec0\u4e48\u8981\u5206\u5272\u4f60\u7684\u7ebf\u7a0b\u6c60\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173114946485109.jpg\" class=\"aligncenter\" title=\"\u7ebf\u7a0b\u6c60\u9694\u79bb\uff1a\u4e3a\u4ec0\u4e48\u8981\u5206\u5272\u4f60\u7684\u7ebf\u7a0b\u6c60\uff1f\u63d2\u56fe\" alt=\"\u7ebf\u7a0b\u6c60\u9694\u79bb\uff1a\u4e3a\u4ec0\u4e48\u8981\u5206\u5272\u4f60\u7684\u7ebf\u7a0b\u6c60\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u7ebf\u7a0b\u6c60\u9694\u79bb\uff1a\u6982\u5ff5\u4e0e\u91cd\u8981\u6027<\/strong><\/p>\n<p><strong>\u7ebf\u7a0b\u6c60\u9694\u79bb\u7684\u6982\u5ff5<\/strong><\/p>\n<p>\u7ebf\u7a0b\u6c60\u9694\u79bb\u662f\u6307\u5c06\u7ebf\u7a0b\u6c60\u5212\u5206\u4e3a\u4e0d\u540c\u7684\u90e8\u5206\uff0c\u6bcf\u4e2a\u90e8\u5206\u6267\u884c\u7279\u5b9a\u7c7b\u578b\u7684\u4efb\u52a1\uff0c\u4ece\u800c\u907f\u514d\u4e0d\u540c\u4efb\u52a1\u4e4b\u95f4\u7684\u5e72\u6270\u3002<\/p>\n<p><strong>\u7ebf\u7a0b\u6c60\u9694\u79bb\u7684\u610f\u4e49<\/strong><\/p>\n<ul>\n<li> <strong>\u63d0\u9ad8\u6027\u80fd\uff1a<\/strong>\u9694\u79bb\u540e\uff0c\u7ebf\u7a0b\u53ef\u4ee5\u4e13\u6ce8\u4e8e\u81ea\u5df1\u7684\u4efb\u52a1\uff0c\u51cf\u5c11\u8d44\u6e90\u4e89\u7528\uff0c\u4ece\u800c\u63d0\u9ad8\u7cfb\u7edf\u6574\u4f53\u6027\u80fd\u3002<\/li>\n<li> <strong>\u589e\u5f3a\u7a33\u5b9a\u6027\uff1a<\/strong>\u5982\u679c\u4e00\u4e2a\u4efb\u52a1\u51fa\u73b0\u6545\u969c\uff0c\u5b83\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u4efb\u52a1\u6216\u4e3b\u7ebf\u7a0b\uff0c\u589e\u5f3a\u7cfb\u7edf\u7684\u53ef\u9760\u6027\u548c\u7a33\u5b9a\u6027\u3002<\/li>\n<li> <strong>\u7b80\u5316\u7ba1\u7406\uff1a<\/strong>\u5c06\u7ebf\u7a0b\u6c60\u9694\u79bb\u540e\u53ef\u4ee5\u66f4\u597d\u5730\u7ec4\u7ec7\u548c\u7ba1\u7406\u4efb\u52a1\uff0c\u4fbf\u4e8e\u76d1\u63a7\u548c\u8c03\u8bd5\u3002<\/li>\n<\/ul>\n<p><strong>spring boot \u4e2d\u7684\u7ebf\u7a0b\u6c60\u9694\u79bb<\/strong><\/p>\n<p>\u5728 spring boot \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e @enableasync \u6ce8\u89e3\u548c taskexecutor \u5b9e\u4f8b\u6765\u5b9e\u73b0\u7ebf\u7a0b\u6c60\u9694\u79bb\u3002<\/p>\n<pre>@SpringBootApplication\npublic class App {\n    public static void main(String[] args) {\n        SpringApplication.run(App.class, args);\n    }\n\n    @Async(\"myTaskExecutor\")\n    public void asyncTask() {\n        \/\/ \u6267\u884c\u5f02\u6b65\u4efb\u52a1\n    }\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>jvm \u4e2d\u7684\u7ebf\u7a0b\u6c60\u6570\u91cf\u9650\u5236<\/strong><\/p>\n<p>jvm \u5bf9\u7ebf\u7a0b\u6570\u91cf\u7684\u9650\u5236\u4e3b\u8981\u662f\u53d7\u5185\u5b58\u5bb9\u91cf\u548c\u914d\u7f6e\u7684\u5f71\u54cd\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u4e00\u4e2a jvm \u53ef\u4ee5\u652f\u6301\u6570\u5343\u4e2a\u7ebf\u7a0b\uff0c\u4f46\u5177\u4f53\u6570\u5b57\u53d6\u51b3\u4e8e\u7cfb\u7edf\u7684\u8d44\u6e90\u914d\u7f6e\u3002<\/p>\n<p>\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a cpu \u6838\u5fc3\u53ef\u4ee5\u540c\u65f6\u6267\u884c\u591a\u4e2a\u7ebf\u7a0b\uff0c\u4f46\u968f\u7740\u7ebf\u7a0b\u6570\u91cf\u7684\u589e\u52a0\uff0c\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u4f1a\u589e\u52a0\uff0c\u5bfc\u81f4\u6027\u80fd\u4e0b\u964d\u3002\u56e0\u6b64\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u7cfb\u7edf\u8d44\u6e90\u548c\u4efb\u52a1\u7279\u6027\u800c\u5b9a\uff0c\u9002\u5f53\u9650\u5236\u7ebf\u7a0b\u6570\u91cf\u662f\u5fc5\u8981\u7684\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u7ebf\u7a0b\u6c60\u9694\u79bb\uff1a\u8981\u5206\u5272\u4f60\u7684\u7ebf\u7a0b\u6c60\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ebf\u7a0b\u6c60\u9694\u79bb\uff1a\u6982\u5ff5\u4e0e\u91cd\u8981\u6027 \u7ebf\u7a0b\u6c60\u9694\u79bb\u7684\u6982\u5ff5 \u7ebf\u7a0b\u6c60\u9694\u79bb\u662f\u6307\u5c06\u7ebf\u7a0b\u6c60\u5212\u5206\u4e3a\u4e0d\u540c\u7684\u90e8\u5206\uff0c\u6bcf\u4e2a\u90e8\u5206\u6267\u884c\u7279\u5b9a\u7c7b\u578b\u7684\u4efb\u52a1\uff0c\u4ece\u800c\u907f\u514d\u4e0d\u540c\u4efb\u52a1\u4e4b\u95f4\u7684\u5e72\u6270\u3002 \u7ebf\u7a0b\u6c60\u9694\u79bb\u7684\u610f\u4e49 \u63d0\u9ad8\u6027\u80fd\uff1a\u9694\u79bb\u540e\uff0c\u7ebf\u7a0b\u53ef\u4ee5\u4e13\u6ce8\u4e8e\u81ea\u5df1\u7684\u4efb\u52a1\uff0c\u51cf\u5c11\u8d44\u6e90\u4e89\u7528\uff0c\u4ece\u800c\u63d0\u9ad8\u7cfb\u7edf\u6574\u4f53\u6027\u80fd\u3002 \u589e\u5f3a\u7a33\u5b9a\u6027\uff1a\u5982\u679c\u4e00\u4e2a\u4efb\u52a1\u51fa\u73b0\u6545\u969c\uff0c\u5b83\u4e0d\u4f1a\u5f71\u54cd\u5176\u4ed6\u4efb\u52a1\u6216\u4e3b\u7ebf\u7a0b\uff0c\u589e\u5f3a\u7cfb\u7edf\u7684\u53ef\u9760\u6027\u548c\u7a33\u5b9a\u6027\u3002 \u7b80\u5316\u7ba1\u7406\uff1a\u5c06\u7ebf\u7a0b\u6c60\u9694\u79bb\u540e\u53ef\u4ee5\u66f4\u597d\u5730\u7ec4\u7ec7\u548c\u7ba1\u7406\u4efb\u52a1\uff0c\u4fbf\u4e8e\u76d1\u63a7\u548c\u8c03\u8bd5\u3002 spring boot \u4e2d\u7684\u7ebf\u7a0b\u6c60\u9694\u79bb \u5728 spring boot \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u914d\u7f6e @enableasync \u6ce8\u89e3\u548c taskexecutor \u5b9e\u4f8b\u6765\u5b9e\u73b0\u7ebf\u7a0b\u6c60\u9694\u79bb\u3002 @SpringBootApplication public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); } @Async(&#8220;myTaskExecutor&#8221;) public void asyncTask() { \/\/ \u6267\u884c\u5f02\u6b65\u4efb\u52a1 } } \u767b\u5f55\u540e\u590d\u5236 jvm \u4e2d\u7684\u7ebf\u7a0b\u6c60\u6570\u91cf\u9650\u5236 jvm \u5bf9\u7ebf\u7a0b\u6570\u91cf\u7684\u9650\u5236\u4e3b\u8981\u662f\u53d7\u5185\u5b58\u5bb9\u91cf\u548c\u914d\u7f6e\u7684\u5f71\u54cd\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u4e00\u4e2a jvm \u53ef\u4ee5\u652f\u6301\u6570\u5343\u4e2a\u7ebf\u7a0b\uff0c\u4f46\u5177\u4f53\u6570\u5b57\u53d6\u51b3\u4e8e\u7cfb\u7edf\u7684\u8d44\u6e90\u914d\u7f6e\u3002 \u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u4e00\u4e2a cpu \u6838\u5fc3\u53ef\u4ee5\u540c\u65f6\u6267\u884c\u591a\u4e2a\u7ebf\u7a0b\uff0c\u4f46\u968f\u7740\u7ebf\u7a0b\u6570\u91cf\u7684\u589e\u52a0\uff0c\u7ebf\u7a0b\u5207\u6362\u5f00\u9500\u4f1a\u589e\u52a0\uff0c\u5bfc\u81f4\u6027\u80fd\u4e0b\u964d\u3002\u56e0\u6b64\uff0c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u7cfb\u7edf\u8d44\u6e90\u548c\u4efb\u52a1\u7279\u6027\u800c\u5b9a\uff0c\u9002\u5f53\u9650\u5236\u7ebf\u7a0b\u6570\u91cf\u662f\u5fc5\u8981\u7684\u3002 \u4ee5\u4e0a\u5c31\u662f\u7ebf\u7a0b\u6c60\u9694\u79bb\uff1a\u8981\u5206\u5272\u4f60\u7684\u7ebf\u7a0b\u6c60\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-65119","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=65119"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65119\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}