{"id":742,"date":"2023-05-28T02:10:40","date_gmt":"2023-05-27T18:10:40","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=742"},"modified":"2023-05-28T02:10:40","modified_gmt":"2023-05-27T18:10:40","slug":"async%e4%b8%80%e4%b8%aa%e6%b3%a8%e8%a7%a3%e6%90%9e%e5%ae%9a%e5%bc%82%e6%ad%a5%e7%bc%96%e7%a8%8b","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/spring-boot\/async%e4%b8%80%e4%b8%aa%e6%b3%a8%e8%a7%a3%e6%90%9e%e5%ae%9a%e5%bc%82%e6%ad%a5%e7%bc%96%e7%a8%8b\/","title":{"rendered":"@Async\u4e00\u4e2a\u6ce8\u89e3\u641e\u5b9a\u5f02\u6b65\u7f16\u7a0b"},"content":{"rendered":"<div class='wxsyncmain'>\n<section class=\"mp_profile_iframe_wrp\"><mpprofile class=\"js_uneditable custom_select_card mp_profile_iframe\" data-pluginname=\"mpprofile\" data-id=\"MzI3ODE5MzczNA==\" data-headimg=\"http:\/\/mmbiz.qpic.cn\/mmbiz_png\/OC2PjnBlMZgkyaeDT9KY7WcbWrxqf5ByXw8PLuXaaVkVNlOHWRyL7Yicw4PLpFqpF8maM8s9wibvQfC1PiaK6QtCA\/0?wx_fmt=png\" data-nickname=\"\u5c0f\u56db\u7684\u6280\u672f\u4e4b\u65c5\" data-alias=\"\" data-signature=\"\u5bfb\u5e38\u7684\u74e6\u820d\u8bc4\u4e66\uff0c\u6697\u85cf\u7740\u6551\u4e16\u79d8\u8bc0\u3002\" data-from=\"0\"><\/mpprofile><\/section>\n<section data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" style=\"color: black;line-height: 1.6;word-spacing: 0px;letter-spacing: 0px;word-break: break-word;overflow-wrap: break-word;text-align: left;font-size: 16px;padding: 10px;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;\">\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;padding: 0px;font-weight: bold;color: black;font-size: 22px;text-align: left;margin: 20px 0px 0px 0px;\"><span style=\"display: none;\"><\/span><span style=\"font-size: 20px;color: #f48a00;display: inline-block;padding-left: 10px;border-left: 8px solid #ffbf52;\">\u524d\u8a00<\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;word-spacing: 0.1em;text-align: justify;color: rgba(0, 0, 0, 0.85);\">\u4e4b\u524d\u5199\u4e86\u51e0\u7bc7\u5173\u4e8e\u5f02\u6b65\u7f16\u7a0b\u7684\u6587\u7ae0\uff0c<code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">Future<\/code>\uff0c<code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">FutureTask<\/code>\uff0c<code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">CompletableFuture<\/code>\uff0c\u4eca\u5929\u6211\u4eec\u6765\u8bf4\u4e00\u4e0b\u53e6\u5916\u4e00\u4e2a\u57fa\u4e8e\u6ce8\u89e3\u7684\u5f02\u6b65\u7f16\u7a0b\u5229\u5668<code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">@Async<\/code>\uff0c\u4f7f\u7528\u5b83\u4ee3\u7801\u4f1a\u66f4\u52a0\u7684\u7b80\u6d01\uff0c\u66f4\u52a0\u7684\u89c4\u8303\uff0c\u4e0d\u8fc7\u5728\u4f7f\u7528\u5b83\u7684\u65f6\u5019\u4e5f\u4f1a\u914d\u5408<code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">Future<\/code>\u63a5\u53e3\uff0c\u4e0b\u9762\u6211\u4eec\u4f1a\u8be6\u7ec6\u7684\u4ecb\u7ecd!<\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;word-spacing: 0.1em;text-align: justify;color: rgba(0, 0, 0, 0.85);\"><a target=\"_blank\" href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MzI3ODE5MzczNA==&amp;mid=2247484471&amp;idx=1&amp;sn=67449f55b1073a89526a8911d75104f8&amp;chksm=eb5bf71edc2c7e0876320a3bea9117106863f88c5e1d582ffab0477574f0ec394d63b835776e&amp;scene=21#wechat_redirect\" textvalue=\"Java\u5e76\u53d1\u7f16\u7a0b\u5f02\u6b65\u64cd\u4f5cFuture\u548cFutureTask\" linktype=\"text\" imgurl=\"\" imgdata=\"null\" data-itemshowtype=\"0\" tab=\"innerlink\" data-linktype=\"2\" rel=\"noopener\" rel=\"nofollow\" >Java\u5e76\u53d1\u7f16\u7a0b\u5f02\u6b65\u64cd\u4f5cFuture\u548cFutureTask<\/a><br  \/><\/p>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;word-spacing: 0.1em;text-align: justify;color: rgba(0, 0, 0, 0.85);\"><a target=\"_blank\" href=\"http:\/\/mp.weixin.qq.com\/s?__biz=MzI3ODE5MzczNA==&amp;mid=2247484566&amp;idx=1&amp;sn=2cddf68fbb6f6d07991d9fa1efbe383a&amp;chksm=eb5bf7bfdc2c7ea96c8d68b1affe0fd8183eac362ea8742725a641c4051a53750c2504bde6d7&amp;scene=21#wechat_redirect\" textvalue=\"Java8\u5f02\u6b65\u5229\u5668CompletableFuture\u7684\u9a9a\u64cd\u4f5c\" linktype=\"text\" imgurl=\"\" imgdata=\"null\" data-itemshowtype=\"0\" tab=\"innerlink\" data-linktype=\"2\" rel=\"noopener\" rel=\"nofollow\" >Java8\u5f02\u6b65\u5229\u5668CompletableFuture\u7684\u9a9a\u64cd\u4f5c<\/a><br  \/><\/p>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;padding: 0px;font-weight: bold;color: black;font-size: 22px;text-align: left;margin: 20px 0px 0px 0px;\"><span style=\"display: none;\"><\/span><span style=\"font-size: 20px;color: #f48a00;display: inline-block;padding-left: 10px;border-left: 8px solid #ffbf52;\">@Async\u89e3\u6790<\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;word-spacing: 0.1em;text-align: justify;color: rgba(0, 0, 0, 0.85);\"><code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">@Async<\/code>\u53ef\u4ee5\u4f7f\u7528\u5728\u65b9\u6cd5\u4e0a\u9762\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5728\u7c7b\u4e0a\u9762\uff0c\u5982\u679c\u5728\u7c7b\u4e0a\u4f7f\u7528\uff0c\u90a3\u4e48\u6574\u4e2a\u7c7b\u7684\u6240\u6709\u65b9\u6cd5\u90fd\u662f\u5f02\u6b65\u7684\uff0c<code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">@Async<\/code>\u6ce8\u89e3\u7684value\u662f\u8bbe\u7f6e\u7ebf\u7a0b\u6c60\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\uff0c\u90a3\u4e48\u5c31\u4f1a\u4f7f\u7528\u9ed8\u8ba4\u7684<code style=\"font-size: 14px;word-wrap: break-word;padding: 2px 4px;border-radius: 4px;margin: 0 2px;background-color: rgba(27,31,35,.05);font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;word-break: break-all;color: #f48a00;\">SimpleAsyncTaskExecutor<\/code>\u7ebf\u7a0b\u6c60\uff0c\u4e0d\u8fc7\u5728\u5b9e\u9645\u4f7f\u7528\u4e2d\uff0c\u6211\u4eec\u80af\u5b9a\u4e0d\u80fd\u4f7f\u7528\u9ed8\u8ba4\u7684\uff0c\u5e94\u8be5\u81ea\u5b9a\u4e49\u4e00\u4e2a\u7ebf\u7a0b\u6c60\u3002<\/p>\n<pre data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 10px;margin-bottom: 10px;border-radius: 5px;box-shadow: rgba(0, 0, 0, 0.55) 0px 2px 10px;\"><span style=\"display: block;background: url(&quot;https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015754490.jpeg&quot;) 10px 10px \/ 40px no-repeat rgb(40, 44, 52);height: 30px;width: 100%;margin-bottom: -7px;border-radius: 5px;\"><\/span><code style=\"overflow-x: auto;padding: 16px;color: #abb2bf;display: -webkit-box;font-family: Operator Mono, Consolas, Monaco, Menlo, monospace;font-size: 12px;-webkit-overflow-scrolling: touch;padding-top: 15px;background: #282c34;border-radius: 5px;\"><span style=\"line-height: 26px;\"><span style=\"color: #c678dd;line-height: 26px;\">public<\/span>&nbsp;String&nbsp;<span style=\"color: #61aeee;line-height: 26px;\">task2<\/span><span style=\"line-height: 26px;\">()<\/span><\/span>{<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;log.info(<span style=\"color: #98c379;line-height: 26px;\">\"=====\u5f00\u59cb\u6267\u884ctask2====={}\"<\/span>,Thread.currentThread().getName());<br  \/>&nbsp;&nbsp;&nbsp;&nbsp;<span style=\"color: #c678dd;line-height: 26px;\">return<\/span>&nbsp;<span style=\"color: #98c379;line-height: 26px;\">\"task2\"<\/span>;<br  \/>}<br  \/><\/code><\/pre>\n<figure data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin: 0;margin-top: 10px;margin-bottom: 10px;display: flex;flex-direction: column;justify-content: center;align-items: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-ratio=\"0.13596059113300493\"  data-type=\"png\" data-w=\"1015\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;display: block;margin: 0px 10px auto;width: 100%;height: 100%;object-fit: contain;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015753933.png\" src=\"https:\/\/s.nmxc.ltd\/sakurairo_vision\/@2.6\/load_svg\/inload.svg\" onerror=\"imgError(this)\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-ratio=\"0.13596059113300493\"  data-type=\"png\" data-w=\"1015\" style=\"max-width: 100%;border-radius: 5px 5px 5px 5px;display: block;margin: 0px 10px auto;width: 100%;height: 100%;object-fit: contain;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015753933.png\"  \/><\/noscript><\/figure>\n<h2 data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"margin-top: 30px;margin-bottom: 15px;padding: 0px;font-weight: bold;color: black;font-size: 22px;text-align: left;margin: 20px 0px 0px 0px;\"><span style=\"display: none;\"><\/span><span style=\"font-size: 20px;color: #f48a00;display: inline-block;padding-left: 10px;border-left: 8px solid #ffbf52;\">\u603b\u7ed3<\/span><\/h2>\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;margin: 5px 0px;line-height: 1.75;letter-spacing: 0.1em;font-size: 16px;word-spacing: 0.1em;text-align: justify;color: rgba(0, 0, 0, 0.85);\">\u4ece\u4e0a\u9762\u6211\u4eec\u53ef\u4ee5\u770b\u51fa\u4f7f\u7528@Async\u8fd8\u662f\u6bd4\u8f83\u7b80\u5355\u7684\uff0c\u7279\u522b\u5bf9\u4e8eSpringBoot\uff0c\u53ea\u9700\u8981\u7b80\u5355\u7684\u6ce8\u89e3\u5c31\u80fd\u5b8c\u4e8b\uff0c\u4e0d\u8fc7\u5728\u4f7f\u7528\u7684\u65f6\u5019\u6211\u4eec\u8981\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u53bb\u8003\u8651\u8be5 \u600e\u4e48\u7528\uff0c\u6bd4\u5982\u6570\u636e\u4e4b\u95f4\u7684\u4f9d\u8d56\uff0c\u8fd4\u56de\u7c7b\u578b\u7b49\u7b49\u3002<\/p>\n<blockquote data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"display: block;font-size: 0.9em;overflow: auto;color: rgb(106, 115, 125);padding: 10px 10px 10px 20px;margin-bottom: 20px;margin-top: 20px;text-size-adjust: 100%;line-height: 1.75em;font-weight: 400;border-radius: 5px;font-style: normal;text-align: left;box-sizing: inherit;border-width: 1px;border-style: solid;border-color: rgb(255, 191, 82);background: rgb(255, 248, 230);\"><p><span style=\"color: #f48a00;font-size: 32px;line-height: 0.6;margin-left: -15px;\">\u275d<\/span><\/p>\n<p style=\"padding-top: 8px;padding-bottom: 8px;letter-spacing: 0.1em;font-size: 16px;word-spacing: 0.1em;text-align: justify;margin: 0px;line-height: 26px;margin-top: -15px;color: rgb(0,0,0,0.85);\">\u4eca\u5929\u7684\u5206\u4eab\u5c31\u5230\u8fd9\u91cc\uff0c\u611f\u8c22\u4f60\u7684\u89c2\u770b\uff0c\u6211\u4eec\u4e0b\u671f\u89c1\uff01<\/p>\n<\/blockquote>\n<\/section>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 \u5218\u724c              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u4e4b\u524d\u5199\u4e86\u51e0\u7bc7\u5173\u4e8e\u5f02\u6b65\u7f16\u7a0b\u7684\u6587\u7ae0\uff0cFuture\uff0cFutureTask\uff0cCompletableFuture\uff0c\u4eca\u5929\u6211\u4eec\u6765\u8bf4\u4e00\u4e0b\u53e6\u5916 &#8230;<\/p>\n","protected":false},"author":2,"featured_media":738,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-742","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-spring-boot"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015751308-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015753933.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015751308-300x127.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015751308.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015753933.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015751308-300x127.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015751308.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015751308.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015753933.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230528015753933.png","id":"image1"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Spring Boot","post_date":"2023-05-27","like_count":"0","praiseWord":"\u9f13\u52b1","copyright_state":"","excitationAd":"0","rewardedVideoAdId":"","detailAdId":"","detailAd":"0","enterpriseMinapp":"0","audios":[],"postImageUrl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2023\/05\/20230519082947553.jpg","avatarurls":[],"related_posts":null,"pageviews":694,"next_post_id":535,"next_post_title":"Controller\u5c42\u4ee3\u7801\u5c31\u8be5\u8fd9\u4e48\u5199\uff0c\u7b80\u6d01\u53c8\u4f18\u96c5\uff01","previous_post_id":583,"previous_post_title":"Springboot \u52a8\u6001\u914d\u7f6e\u53ca\u4e00\u952e\u6253\u5305\u90e8\u7f72","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/742","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=742"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/742\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/738"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=742"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=742"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=742"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}