{"id":5803,"date":"2024-08-01T22:46:24","date_gmt":"2024-08-01T14:46:24","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/?p=5803"},"modified":"2024-08-01T22:46:24","modified_gmt":"2024-08-01T14:46:24","slug":"%e6%89%93%e9%80%a0%e8%b6%85%e9%ab%98%e6%80%a7%e8%83%bd%e7%9a%84%e6%8e%a5%e5%8f%a3api%e7%9a%8412%e4%b8%aa%e6%8a%80%e5%b7%a7","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/java\/%e6%89%93%e9%80%a0%e8%b6%85%e9%ab%98%e6%80%a7%e8%83%bd%e7%9a%84%e6%8e%a5%e5%8f%a3api%e7%9a%8412%e4%b8%aa%e6%8a%80%e5%b7%a7\/","title":{"rendered":"\u6253\u9020\u8d85\u9ad8\u6027\u80fd\u7684\u63a5\u53e3API\u768412\u4e2a\u6280\u5de7~"},"content":{"rendered":"<div class='wxsyncmain'>\n<fieldset style=\"margin: 0.8em 33.5px 0.3em;color: rgb(62, 62, 62);font-size: 16px;white-space: normal;max-width: 100%;box-sizing: border-box;min-width: 0px;line-height: 25.6px;border-width: initial;border-style: initial;border-color: currentcolor;text-align: center;background-color: rgb(255, 255, 255);overflow-wrap: break-word !important;\" data-mpa-powered-by=\"yiban.io\">\n<section class=\"mp_profile_iframe_wrp\"><mp-common-profile class=\"js_uneditable custom_select_card mp_profile_iframe\" data-pluginname=\"mpprofile\" data-id=\"MzAwMTk4NjM1MA==\" data-headimg=\"http:\/\/mmbiz.qpic.cn\/mmbiz_png\/PxMzT0Oibf4gcBzLSUNh2cgXUsuLIsvQYJE1lzZd74qpC3iciaM6gcYIfOVV0KjDDkeN4CTLTn4ETPtaHOAuTWSWA\/0?wx_fmt=png\" data-nickname=\"JAVA\u65e5\u77e5\u5f55\" data-alias=\"javadaily\" data-signature=\"\u5199\u4ee3\u7801\u7684\u67b6\u6784\u5e08\uff0c\u505a\u67b6\u6784\u7684\u7a0b\u5e8f\u5458\uff01  \u5b9e\u6218\u3001\u6e90\u7801\u3001\u6570\u636e\u5e93\u3001\u67b6\u6784...\u53ea\u8981\u4f60\u6765\uff0c\u4f60\u60f3\u4e86\u89e3\u7684\u8fd9\u91cc\u90fd\u6709\uff01\" data-from=\"0\" data-is_biz_ban=\"0\"><\/mp-common-profile><\/section>\n<\/fieldset>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">1. \u5e76\u884c\u5904\u7406<\/h1>\n<h3 style=\"font-family: &#39;Microsoft YaHei&#39;;letter-spacing: normal;text-align: left;line-height: 1.2;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7b80\u8981\u8bf4\u660e<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e3e\u4e2a\u4f8b\u5b50\uff1a\u5728\u4ef7\u683c\u67e5\u8be2\u94fe\u8def\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u83b7\u53d6\u591a\u79cd\u72ec\u7acb\u7684\u4ef7\u683c\u914d\u7f6e\u9879\u4fe1\u606f\uff0c\u5982\u57fa\u7840\u4ef7\u3001\u6298\u6263\u4ef7\u3001\u5546\u6237\u6d3b\u52a8\u4ef7\u3001\u5e73\u53f0\u6d3b\u52a8\u4ef7\u7b49\u7b49\u3002\u4e3a\u4e86\u52a0\u5feb\u5904\u7406\u901f\u5ea6\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u7ebf\u7a0b\u5e76\u884c\u5904\u7406\u7684\u65b9\u5f0f\uff0c\u5229\u7528\u5e76\u53d1\u8ba1\u7b97\u7684\u4f18\u52bf\u3002\u800c<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5b9e\u73b0\u591a\u7ebf\u7a0b\u7684\u65b9\u5f0f\uff0c\u5b83\u53ef\u4ee5\u8f7b\u677e\u5730\u7ba1\u7406\u7ebf\u7a0b\u7684\u521b\u5efa\u3001\u6267\u884c\u548c\u56de\u8c03\uff0c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u53ef\u6269\u5c55\u6027\u548c\u5e76\u53d1\u6027\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7136\u800c\uff0c\u591a\u7ebf\u7a0b\u7684\u4f7f\u7528\u4e5f\u5b58\u5728\u4e00\u4e9b\u5f0a\u7aef\uff0c\u4f8b\u5982\u786c\u4ef6\u8d44\u6e90\u7684\u9650\u5236\u548c\u7ebf\u7a0b\u95f4\u7684\u901a\u4fe1\u5f00\u9500\u7b49\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u5728\u4f7f\u7528\u591a\u7ebf\u7a0b\u7684\u540c\u65f6\uff0c\u8003\u8651\u5230 I\/O \u5bc6\u96c6\u578b\u548c CPU \u5bc6\u96c6\u578b\u7684\u5dee\u5f02\uff0c\u4ee5\u907f\u514d\u8fc7\u5ea6\u5f00\u542f\u7ebf\u7a0b\u5bfc\u81f4\u6027\u80fd\u4e0b\u964d\u3002\u540c\u65f6\uff0c\u5bf9\u4e8e\u7ebf\u7a0b\u6c60\u7684\u8fd0\u884c\u60c5\u51b5\uff0c\u6211\u4eec\u4e5f\u9700\u8981\u6709\u4e00\u5b9a\u7684\u4e86\u89e3\u548c\u63a7\u5236\uff0c\u4ee5\u786e\u4fdd\u7a0b\u5e8f\u7684\u9ad8\u6548\u7a33\u5b9a\u8fd0\u884c\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">CompletableFuture \u662f\u94f6\u5f39\u5417\uff1f<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6211\u4eec\u5e38\u8bf4\u201c\u624b\u62ff\u9524\u5b50\u770b\u4ec0\u4e48\u90fd\u50cf\u9489\u5b50\u201d\uff0c\u4f7f\u7528<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u7684\u786e\u80fd\u591f\u5e2e\u52a9\u6211\u4eec\u89e3\u51b3\u8bb8\u591a\u72ec\u7acb\u5904\u7406\u903b\u8f91\u7684\u95ee\u9898\uff0c\u4f46\u662f\u5982\u679c\u4f7f\u7528\u8fc7\u591a\u7684\u7ebf\u7a0b\uff0c\u53cd\u800c\u4f1a\u5bfc\u81f4\u7ebf\u7a0b\u8c03\u5ea6\u65f6\u95f4\u4e0d\u80fd\u5f97\u5230\u4fdd\u969c\uff0c\u7ebf\u7a0b\u4f1a\u88ab\u6d6a\u8d39\u5728\u7b49\u5f85 CPU \u65f6\u95f4\u7247\u4e0a\uff0c\u7279\u522b\u662f\u5bf9\u4e8e\u90a3\u4e9b\u672c\u6765\u6267\u884c\u901f\u5ea6\u5c31\u5f88\u5feb\u7684\u4efb\u52a1\uff0c\u4f7f\u7528 CompletableFuture \u4e4b\u540e\u53cd\u800c\u4f1a\u62d6\u6162\u6574\u4f53\u6267\u884c\u65f6\u957f\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u56e0\u6b64\uff0c\u5728\u4f7f\u7528<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u65f6\uff0c\u6211\u4eec\u9700\u8981\u6839\u636e\u5177\u4f53\u7684\u573a\u666f\u548c\u4efb\u52a1\uff0c\u4ed4\u7ec6\u8003\u8651\u662f\u5426\u9700\u8981\u5e76\u884c\u5904\u7406\u3002\u5982\u679c\u9700\u8981\u5e76\u884c\u5904\u7406\uff0c\u6211\u4eec\u9700\u8981\u6839\u636e\u4efb\u52a1\u7684\u6027\u8d28\u548c\u6267\u884c\u901f\u5ea6\uff0c\u9009\u62e9\u5408\u9002\u7684\u7ebf\u7a0b\u6c60\u5927\u5c0f\u548c\u5e76\u884c\u7ebf\u7a0b\u6570\u91cf\uff0c\u4ee5\u907f\u514d\u7ebf\u7a0b\u8c03\u5ea6\u65f6\u95f4\u7684\u6d6a\u8d39\u548c\u6267\u884c\u6548\u7387\u7684\u4e0b\u964d\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u6d4b\u8bd5\u6848\u4f8b<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6267\u884c a,b,c,d4 \u4e2a\u65b9\u6cd5\uff0c\u6bd4\u8f83\u540c\u6b65\u6267\u884c\u4e0e\u5f02\u6b65\u6267\u884c\u7684\u8017\u65f6\u60c5\u51b5\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u5168\u540c\u6b65\u6267\u884c<\/h4>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">test<\/span>(){<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">s<\/span>=System.currentTimeMillis();a(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);b(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);c(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);d(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e<\/span>=System.currentTimeMillis();System.out.println(e-s);}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">a<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span>time){<span style=\"color: rgb(198, 120, 221);\">try<\/span>{Thread.sleep(time);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">b<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span>time){<span style=\"color: rgb(198, 120, 221);\">try<\/span>{Thread.sleep(time);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">c<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span>time){<span style=\"color: rgb(198, 120, 221);\">try<\/span>{Thread.sleep(time);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">d<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span>time){<span style=\"color: rgb(198, 120, 221);\">try<\/span>{Thread.sleep(time);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}}<\/code><\/pre>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u5168\u5f02\u6b65\u6267\u884c<\/h4>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">test2<\/span>(){<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">s<\/span>=System.currentTimeMillis();List&lt;CompletableFuture&lt;?&gt;&gt;completableFutureList=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ArrayList<\/span>&lt;&gt;();CompletableFuture&lt;Void&gt;future1=CompletableFuture.runAsync(()-&gt;{a(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);});completableFutureList.add(future1);CompletableFuture&lt;Void&gt;future2=CompletableFuture.runAsync(()-&gt;{b(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);});completableFutureList.add(future2);CompletableFuture&lt;Void&gt;future3=CompletableFuture.runAsync(()-&gt;{c(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);});completableFutureList.add(future3);CompletableFuture&lt;Void&gt;future4=CompletableFuture.runAsync(()-&gt;{d(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);});completableFutureList.add(future4);CompletableFuture&lt;?&gt;[]futures=completableFutureList.toArray(<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">CompletableFuture<\/span>[<span style=\"color: rgb(209, 154, 102);\">0<\/span>]);CompletableFuture&lt;Void&gt;futureAll=CompletableFuture.allOf(futures);futureAll.join();<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e<\/span>=System.currentTimeMillis();System.out.println(e-s);}<\/code><\/pre>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u7ed3\u679c\u7edf\u8ba1<\/h4>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-galleryid=\"\" data-imgfileid=\"100036994\" data-ratio=\"0.9115853658536586\" data-s=\"300,640\" data-type=\"png\" data-w=\"656\"  style=\";\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222613481.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-galleryid=\"\" data-imgfileid=\"100036994\" data-ratio=\"0.9115853658536586\" data-s=\"300,640\" data-type=\"png\" data-w=\"656\"  style=\";\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222613481.png\"  \/><\/noscript><\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u6d4b\u8bd5\u7ed3\u8bba<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u5206\u914d\u4e86\u76f8\u5bf9\u5408\u7406\u7684\u7ebf\u7a0b\u6c60\u7684\u60c5\u51b5\u4e0b\uff0c\u901a\u8fc7\u4ee5\u4e0a\u5206\u6790\uff0c\u53ef\u4ee5\u5f97\u51fa\u4e0b\u5217\u4e24\u4e2a\u7ed3\u8bba\uff1a<\/p>\n<ul style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022\u65b9\u6cd5\u8017\u65f6\u8d8a\u5c11\uff0c\u540c\u6b65\u6bd4\u5f02\u6b65\u8d8a\u597d\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022\u65b9\u6cd5\u6570\u91cf\u8d8a\u5c11\uff0c\u540c\u6b65\u6bd4\u5f02\u6b65\u8d8a\u597d\u3002<\/p>\n<\/li>\n<\/ul>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u534a\u5f02\u6b65\uff0c\u534a\u540c\u6b65<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6709\u65f6\u5019\uff0c\u5982\u679c\u65b9\u6cd5\u8f83\u591a\uff0c\u4e3a\u4e86\u51cf\u5c11\u9ad8\u5e76\u53d1\u65f6 P99 \u8f83\u9ad8\uff0c\u6211\u4eec\u53ef\u4ee5\u8ba9\u8017\u65f6\u591a\u7684\u65b9\u6cd5\u5f02\u6b65\u6267\u884c\uff0c\u8017\u65f6\u5c11\u7684\u65b9\u6cd5\u540c\u6b65\u6267\u884c\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u901a\u8fc7\u4ee5\u4e0b\u6570\u636e\u53ef\u4ee5\u770b\u51fa\uff0c\u8017\u65f6\u662f\u5dee\u4e0d\u591a\u7684\uff0c\u4f46\u53ef\u4ee5\u8282\u7701\u4e0d\u5c11\u7ebf\u7a0b\u8d44\u6e90\u3002<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-galleryid=\"\" data-imgfileid=\"100036993\" data-ratio=\"0.38181818181818183\" data-s=\"300,640\" data-type=\"png\" data-w=\"660\"  style=\";\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222618261.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-galleryid=\"\" data-imgfileid=\"100036993\" data-ratio=\"0.38181818181818183\" data-s=\"300,640\" data-type=\"png\" data-w=\"660\"  style=\";\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222618261.png\"  \/><\/noscript><\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u603b\u7ed3<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u63d0\u4f9b\u4e86\u4e00\u79cd\u4f18\u96c5\u800c\u5f3a\u5927\u7684\u65b9\u5f0f\u6765\u5904\u7406\u5e76\u53d1\u8bf7\u6c42\u548c\u4efb\u52a1\u3002\u7136\u800c\uff0c\u6b63\u5982\u5728\u5904\u7406\u9ad8\u5e76\u53d1\u65f6\u4f7f\u7528\u8fc7\u591a\u7684\u7ebf\u7a0b\u4f1a\u5bfc\u81f4\u8d44\u6e90\u6d6a\u8d39\u548c\u6548\u7387\u4e0b\u964d\u4e00\u6837\uff0c\u4f7f\u7528\u8fc7\u591a\u7684<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u4e5f\u4f1a\u5bfc\u81f4\u540c\u6837\u7684\u95ee\u9898\u3002\u8fd9\u79cd\u73b0\u8c61\u88ab\u79f0\u4e3a \"\u7ebf\u7a0b\u8c03\u5ea6\u95ee\u9898\"\uff0c\u5b83\u4f1a\u5bfc\u81f4\u6027\u80fd\u4e0b\u964d\u548c\u541e\u5410\u91cf\u4e0b\u964d\uff08P99 \u503c\u8f83\u9ad8\uff09\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u56e0\u6b64\uff0c\u6211\u4eec\u9700\u8981\u5728\u4f7f\u7528<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u65f6\u8003\u8651\u5b9e\u9645\u573a\u666f\u548c\u8d1f\u8f7d\u60c5\u51b5\uff0c\u5e76\u6839\u636e\u9700\u8981\u4f7f\u7528\u6070\u5f53\u7684\u6280\u672f\u6765\u4f18\u5316\u6027\u80fd\u3002<\/p>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">2. \u6700\u5c0f\u5316\u4e8b\u52a1\u8303\u56f4<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7b80\u8981\u8bf4\u660e<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u660e\u786e\u7684\u662f\uff0c\u4e8b\u52a1\u7684\u5b58\u5728\u52bf\u5fc5\u4f1a\u5bf9\u6027\u80fd\u4ea7\u751f\u5f71\u54cd\uff0c\u7279\u522b\u662f\u5728\u9ad8\u5e76\u53d1\u7684\u60c5\u51b5\u4e0b\uff0c\u56e0\u4e3a\u9501\u7684\u7ade\u4e89\uff0c\u4f1a\u5e26\u6765\u6781\u5927\u7684\u6027\u80fd\u635f\u8017\u3002\u56e0\u6b64\uff0c\u5728\u5904\u7406\u6570\u636e\u4ea4\u4e92\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u59cb\u7ec8\u575a\u6301\u5c3d\u53ef\u80fd\u5730\u51cf\u5c11\u4e8b\u52a1\u7684\u8303\u56f4\uff0c\u4ece\u800c\u63d0\u5347\u63a5\u53e3\u7684\u54cd\u5e94\u901f\u5ea6\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e00\u822c\u6765\u8bf4\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">@Transactional<\/code>\u6ce8\u89e3\u8f7b\u677e\u5b9e\u73b0\u4e8b\u52a1\u7684\u63a7\u5236\u3002\u4f46\u662f\uff0c\u7531\u4e8e<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">@Transactional<\/code>\u6ce8\u89e3\u7684\u6700\u5c0f\u7c92\u5ea6\u4ec5\u9650\u4e8e\u65b9\u6cd5\u7ea7\u522b\uff0c\u56e0\u6b64\uff0c\u4e3a\u4e86\u66f4\u597d\u5730\u63a7\u5236\u4e8b\u52a1\u7684\u8303\u56f4\uff0c\u6211\u4eec\u9700\u8981\u901a\u8fc7\u7f16\u7a0b\u5f0f\u4e8b\u52a1\u6765\u5b9e\u73b0\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u7f16\u7a0b\u5f0f\u4e8b\u52a1\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u7075\u6d3b\u5730\u63a7\u5236\u4e8b\u52a1\u7684\u5f00\u542f\u548c\u7ed3\u675f\uff0c\u4ee5\u53ca\u5bf9\u6570\u636e\u5e93\u64cd\u4f5c\u7684\u5904\u7406\u3002\u901a\u8fc7\u9002\u5f53\u7684\u8bbe\u7f6e\u4e8b\u52a1\u53c2\u6570\u548c\u64cd\u4f5c\u89c4\u5219\uff0c\u6211\u4eec\u53ef\u4ee5\u5b9e\u73b0\u4e8b\u52a1\u7684\u6700\u5c0f\u5316\uff0c\u4ece\u800c\u63d0\u5347\u7cfb\u7edf\u7684\u6027\u80fd\u548c\u53ef\u9760\u6027\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7f16\u7a0b\u5f0f\u4e8b\u52a1\u6a21\u677f<\/h3>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">interface<\/span><span style=\"color: rgb(230, 192, 123);\">TransactionControlService<\/span>{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u4e8b\u52a1\u5904\u7406**<span style=\"color: rgb(198, 120, 221);\">@param<\/span>objectLogicFunction\u4e1a\u52a1\u903b\u8f91*<span style=\"color: rgb(198, 120, 221);\">@param<\/span>&lt;T&gt;resulttype*<span style=\"color: rgb(198, 120, 221);\">@return<\/span>\u5904\u7406\u7ed3\u679c*<span style=\"color: rgb(198, 120, 221);\">@throws<\/span>Exception\u4e1a\u52a1\u5f02\u5e38\u4fe1\u606f*\/<\/span>&lt;T&gt;T<span style=\"color: rgb(97, 174, 238);\">execute<\/span>(ObjectLogicFunction&lt;T&gt;objectLogicFunction)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>Exception;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u4e8b\u52a1\u5904\u7406**<span style=\"color: rgb(198, 120, 221);\">@param<\/span>voidLogicFunction\u4e1a\u52a1\u903b\u8f91*<span style=\"color: rgb(198, 120, 221);\">@throws<\/span>Exception\u4e1a\u52a1\u5f02\u5e38\u4fe1\u606f*\/<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">execute<\/span>(VoidLogicFunctionvoidLogicFunction)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>Exception;}<\/code><\/pre>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(97, 174, 238);\">@Service<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">TransactionControlServiceImpl<\/span><span style=\"color: rgb(198, 120, 221);\">implements<\/span><span style=\"color: rgb(230, 192, 123);\">TransactionControlService<\/span>{<span style=\"color: rgb(97, 174, 238);\">@Autowired<\/span><span style=\"color: rgb(198, 120, 221);\">private<\/span>PlatformTransactionManagerplatformTransactionManager;<span style=\"color: rgb(97, 174, 238);\">@Autowired<\/span><span style=\"color: rgb(198, 120, 221);\">private<\/span>TransactionDefinitiontransactionDefinition;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u4e8b\u52a1\u5904\u7406**<span style=\"color: rgb(198, 120, 221);\">@param<\/span>businessLogic\u4e1a\u52a1\u903b\u8f91*<span style=\"color: rgb(198, 120, 221);\">@param<\/span>&lt;T&gt;resulttype*<span style=\"color: rgb(198, 120, 221);\">@return<\/span>\u5904\u7406\u7ed3\u679c*<span style=\"color: rgb(198, 120, 221);\">@throws<\/span>Exception\u4e1a\u52a1\u5f02\u5e38\u4fe1\u606f*\/<\/span><span style=\"color: rgb(97, 174, 238);\">@Override<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span>&lt;T&gt;T<span style=\"color: rgb(97, 174, 238);\">execute<\/span>(ObjectLogicFunction&lt;T&gt;businessLogic)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>Exception{<span style=\"color: rgb(209, 154, 102);\">TransactionStatus<\/span><span style=\"color: rgb(209, 154, 102);\">transactionStatus<\/span>=platformTransactionManager.getTransaction(transactionDefinition);<span style=\"color: rgb(198, 120, 221);\">try<\/span>{<span style=\"color: rgb(209, 154, 102);\">T<\/span><span style=\"color: rgb(209, 154, 102);\">resp<\/span>=businessLogic.logic();platformTransactionManager.commit(transactionStatus);<span style=\"color: rgb(198, 120, 221);\">return<\/span>resp;}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(Exceptione){platformTransactionManager.rollback(transactionStatus);<span style=\"color: rgb(198, 120, 221);\">throw<\/span><span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Exception<\/span>(e);}}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u4e8b\u52a1\u5904\u7406**<span style=\"color: rgb(198, 120, 221);\">@param<\/span>businessLogic\u4e1a\u52a1\u903b\u8f91*\/<\/span><span style=\"color: rgb(97, 174, 238);\">@Override<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">execute<\/span>(VoidLogicFunctionbusinessLogic)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>Exception{<span style=\"color: rgb(209, 154, 102);\">TransactionStatus<\/span><span style=\"color: rgb(209, 154, 102);\">transactionStatus<\/span>=platformTransactionManager.getTransaction(transactionDefinition);<span style=\"color: rgb(198, 120, 221);\">try<\/span>{businessLogic.logic();platformTransactionManager.commit(transactionStatus);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(Exceptione){platformTransactionManager.rollback(transactionStatus);<span style=\"color: rgb(198, 120, 221);\">throw<\/span><span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Exception<\/span>(e);}}}<\/code><\/pre>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(97, 174, 238);\">@FunctionalInterface<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">interface<\/span><span style=\"color: rgb(230, 192, 123);\">ObjectLogicFunction<\/span>&lt;T&gt;{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u4e1a\u52a1\u903b\u8f91\u5904\u7406**<span style=\"color: rgb(198, 120, 221);\">@return<\/span>\u4e1a\u52a1\u5904\u7406\u7ed3\u679c*<span style=\"color: rgb(198, 120, 221);\">@throws<\/span>BusinessExceptione*\/<\/span>T<span style=\"color: rgb(97, 174, 238);\">logic<\/span>()<span style=\"color: rgb(198, 120, 221);\">throws<\/span>BusinessException;}<\/code><\/pre>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(97, 174, 238);\">@FunctionalInterface<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">interface<\/span><span style=\"color: rgb(230, 192, 123);\">VoidLogicFunction<\/span>{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u4e1a\u52a1\u903b\u8f91\u5904\u7406**<span style=\"color: rgb(198, 120, 221);\">@throws<\/span>Exceptione*\/<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">logic<\/span>()<span style=\"color: rgb(198, 120, 221);\">throws<\/span>Exception;}<\/code><\/pre>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">transactionControlService.execute(()-&gt;{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u628a\u9700\u8981\u4e8b\u52a1\u63a7\u5236\u7684\u4e1a\u52a1\u903b\u8f91\u5199\u5728\u8fd9\u91cc\u5373\u53ef<\/span>});<\/code><\/pre>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">3. \u7f13\u5b58<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7b80\u8981\u8bf4\u660e<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7f13\u5b58\uff0c\u8fd9\u4e00\u5728\u6027\u80fd\u63d0\u5347\u65b9\u9762\u582a\u79f0\u4e07\u91d1\u6cb9\u7684\u6280\u672f\u624b\u6bb5\uff0c\u5b83\u7684\u91cd\u8981\u6027\u5728\u5404\u79cd\u8ba1\u7b97\u673a\u5e94\u7528\u9886\u57df\u4e2d\u65e0\u53ef\u6bd4\u62df\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7f13\u5b58\u4f5c\u4e3a\u4e00\u79cd\u9ad8\u6548\u7684\u6570\u636e\u8bfb\u53d6\u548c\u5199\u5165\u7684\u4f18\u5316\u65b9\u5f0f\uff0c\u88ab\u5e7f\u6cdb\u5e94\u7528\u4e8e\u5404\u79cd\u9886\u57df\uff0c\u5305\u62ec\u7535\u5546\u3001\u91d1\u878d\u3001\u6e38\u620f\u3001\u76f4\u64ad\u7b49\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u867d\u7136\u5728\u7f51\u7edc\u4e0a\u5173\u4e8e\u7f13\u5b58\u7684\u6587\u7ae0\u4e0d\u80dc\u679a\u4e3e\uff0c\u4f46\u8981\u60f3\u5145\u5206\u53d1\u6325\u7f13\u5b58\u7684\u4f5c\u7528\uff0c\u9700\u8981\u9488\u5bf9\u5177\u4f53\u7684\u4e1a\u52a1\u573a\u666f\u8fdb\u884c\u6df1\u5165\u5206\u6790\u548c\u63a2\u8ba8\u3002\u56e0\u6b64\uff0c\u5728\u672c\u8282\u4e2d\uff0c\u6211\u4eec\u5c06\u4e0d\u8fc7\u591a\u8d58\u8ff0\u7f13\u5b58\u7684\u5177\u4f53\u4f7f\u7528\u65b9\u6cd5\uff0c\u800c\u662f\u91cd\u70b9\u5217\u4e3e\u4e00\u4e9b\u4f7f\u7528\u7f13\u5b58\u65f6\u7684\u6ce8\u610f\u4e8b\u9879.<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u4f7f\u7528\u7f13\u5b58\u65f6\u7684\u6ce8\u610f\u4e8b\u9879<\/h4>\n<ul style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u8fc7\u671f\u65f6\u95f4\uff1a<\/strong>\u8bbe\u7f6e\u5408\u9002\u7684\u8fc7\u671f\u65f6\u95f4\u53ef\u4ee5\u4fdd\u8bc1\u7f13\u5b58\u7684\u6709\u6548\u6027\uff0c\u4f46\u8fc7\u671f\u65f6\u95f4\u8fc7\u957f\u53ef\u80fd\u4f1a\u6d6a\u8d39\u5185\u5b58\u7a7a\u95f4\uff0c\u8fc7\u671f\u65f6\u95f4\u8fc7\u77ed\u53ef\u80fd\u4f1a\u5bfc\u81f4\u9891\u7e41\u5237\u65b0\u7f13\u5b58\uff0c\u5f71\u54cd\u6027\u80fd\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u4e00\u81f4\u6027\uff1a<\/strong>\u5982\u679c\u7f13\u5b58\u7684\u6570\u636e\u4e0e\u6570\u636e\u5e93\u4e2d\u7684\u6570\u636e\u4e0d\u4e00\u81f4\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e1a\u52a1\u903b\u8f91\u51fa\u73b0\u95ee\u9898\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528\u7f13\u5b58\u65f6\u9700\u8981\u8003\u8651\u7f13\u5b58\u4e00\u81f4\u6027\u7684\u95ee\u9898\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u5bb9\u91cf\u9650\u5236\uff1a<\/strong>\u7f13\u5b58\u5bb9\u91cf\u6709\u9650\uff0c\u5982\u679c\u7f13\u5b58\u7684\u6570\u636e\u91cf\u8fc7\u5927\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u5185\u5b58\u6ea2\u51fa\u6216\u8005\u7f13\u5b58\u9891\u7e41\u6e05\u7406\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528\u7f13\u5b58\u65f6\u9700\u8981\u6ce8\u610f\u7f13\u5b58\u5bb9\u91cf\u7684\u9650\u5236\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u9700\u8981\u8003\u8651\u8d1f\u8f7d\u5747\u8861\uff1a<\/strong>\u5728\u9ad8\u5e76\u53d1\u573a\u666f\u4e0b\uff0c\u9700\u8981\u8003\u8651\u7f13\u5b58\u7684\u8d1f\u8f7d\u5747\u8861\u95ee\u9898\uff0c\u907f\u514d\u67d0\u4e9b\u7f13\u5b58\u670d\u52a1\u5668\u56e0\u4e3a\u70ed\u70b9\u6570\u636e\u7b49\u95ee\u9898\u8d1f\u8f7d\u8fc7\u91cd\u5bfc\u81f4\u7cfb\u7edf\u5d29\u6e83\u6216\u8005\u54cd\u5e94\u53d8\u6162\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u9700\u8981\u8003\u8651\u5e76\u53d1\u8bfb\u5199\uff1a<\/strong>\u5f53\u591a\u4e2a\u7528\u6237\u540c\u65f6\u8bbf\u95ee\u7f13\u5b58\u65f6\uff0c\u9700\u8981\u8003\u8651\u5e76\u53d1\u8bfb\u5199\u7684\u95ee\u9898\uff0c\u907f\u514d\u7f13\u5b58\u51b2\u7a81\u548c\u6570\u636e\u4e00\u81f4\u6027\u95ee\u9898\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u7a7f\u900f\u95ee\u9898\uff1a<\/strong>\u5f53\u5927\u91cf\u7684\u67e5\u8be2\u8bf7\u6c42\u90fd\u65e0\u6cd5\u547d\u4e2d\u7f13\u5b58\u65f6\uff0c\u5bfc\u81f4\u6bcf\u6b21\u67e5\u8be2\u90fd\u4f1a\u843d\u5230\u6570\u636e\u5e93\u4e0a\uff0c\u4ece\u800c\u9020\u6210\u6570\u636e\u5e93\u538b\u529b\u8fc7\u5927\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u51fb\u7a7f\u95ee\u9898\uff1a<\/strong>\u5f53\u7f13\u5b58\u6570\u636e\u5931\u6548\u540e\uff0c\u5bfc\u81f4\u5927\u91cf\u7684\u8bf7\u6c42\u76f4\u63a5\u6253\u5230\u6570\u636e\u5e93\u4e2d\uff0c\u4ece\u800c\u9020\u6210\u6570\u636e\u5e93\u538b\u529b\u8fc7\u5927\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u67e5\u8be2\u65f6\u95f4\u590d\u6742\u5ea6\uff1a<\/strong>\u9700\u989d\u5916\u6ce8\u610f\u7f13\u5b58\u67e5\u8be2\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u95ee\u9898\uff0c\u5982\u679c\u662f O(n)\uff0c\u751a\u81f3\u66f4\u5dee\u7684\u65f6\u95f4\u590d\u6742\u5ea6\uff0c\u5219\u4f1a\u56e0\u4e3a\u7f13\u5b58\u7684\u6570\u636e\u91cf\u589e\u52a0\u800c\u8ddf\u7740\u589e\u52a0\u3002<\/p>\n<\/li>\n<\/ul>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u8003\u8651\u5230\u8fd9\u4e9b\u95ee\u9898\u901a\u5e38\u4f18\u5316\u7684\u624b\u6bb5<\/h4>\n<ul style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u6570\u636e\u538b\u7f29\uff1a<\/strong>\u9009\u62e9\u5408\u7406\u7684\u6570\u636e\u7c7b\u578b\uff0c\u4e3e\u4e2a\u4f8b\u5b50\uff1a\u5982\u679c\u7528<code style=\"line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">Integer[]<\/code> \u548c<code style=\"line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">int[]<\/code>\u6765\u6bd4\u8f83\uff0cInteger \u5360\u7528\u7684\u7a7a\u95f4\u5927\u7ea6\u662f int \u7684 4 \u500d\u3002\u5176\u4ed6\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528\u4e00\u4e9b\u5e38\u89c1\u6570\u636e\u7f16\u7801\u538b\u7f29\u6280\u672f\u4e5f\u662f\u5e38\u89c1\u7684\u8282\u7701\u5185\u5b58\u7684\u65b9\u5f0f\uff0c\u6bd4\u5982\uff1aBitMap\u3001\u5b57\u5178\u7f16\u7801\u7b49\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u9884\u52a0\u8f7d\uff1a<\/strong>\u5f53\u884c\u4e3a\u53ef\u9884\u6d4b\u65f6\uff0c\u90a3\u4e48\u63d0\u524d\u52a0\u8f7d\u4fbf\u53ef\u89e3\u51b3\u6784\u5efa\u7f13\u5b58\u65f6\u7684\u538b\u529b\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u70ed\u70b9\u6570\u636e\uff1a<\/strong>\u70ed\u70b9\u6570\u636e\u5982\u679c\u4e0d\u80fd\u6253\u6563\uff0c\u90a3\u4e48\u901a\u5e38\u5c31\u4f1a\u6784\u5efa\u591a\u7ea7\u7f13\u5b58\uff0c\u6bd4\u5982\u5c06\u5e94\u7528\u670d\u52a1\u8bbe\u4e3a\u4e00\u7ea7\u7f13\u5b58\uff0cRedis \u8bbe\u4e3a\u4e8c\u7ea7\u7f13\u5b58\uff0c\u4e00\u7ea7\u7f13\u5b58\uff0c\u7f13\u5b58\u5168\u91cf\u70ed\u70b9\u6570\u636e\uff0c\u4ece\u800c\u5b9e\u73b0\u538b\u529b\u5206\u644a\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u7f13\u5b58\u7a7f\u900f\u3001\u51fb\u7a7f\uff1a<\/strong>\u9488\u5bf9\u547d\u4e2d\u4e0d\u4e86\u7f13\u5b58\u7684\u67e5\u8be2\u4e5f\u53ef\u4ee5\u7f13\u5b58\u4e00\u4e2a\u989d\u5916\u7684\u6807\u8bc6\uff1b\u800c\u9488\u5bf9\u7f13\u5b58\u5931\u6548\uff0c\u8981\u4e48\u5c31\u5728\u5931\u6548\u524d\uff0c\u4e3b\u52a8\u5237\u65b0\u4e00\u6b21\uff0c\u8981\u4e48\u5c31\u5206\u6563\u5931\u6548\u65f6\u95f4\uff0c\u907f\u514d\u5927\u91cf\u7f13\u5b58\u540c\u65f6\u5931\u6548\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">\u65f6\u95f4\u590d\u6742\u5ea6\uff1a<\/strong>\u5728\u8bbe\u8ba1\u7f13\u5b58\u65f6\uff0c\u4f18\u5148\u8003\u8651\u9009\u62e9\u5e38\u6570\u7ea7\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u7684\u65b9\u6cd5\u3002<\/p>\n<\/li>\n<\/ul>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">4. \u5408\u7406\u4f7f\u7528\u7ebf\u7a0b\u6c60<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7b80\u8981\u8bf4\u660e<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u672c\u6587\u5f00\u59cb\u63d0\u5230\u7684\u4f7f\u7528<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u5e76\u884c\u5904\u7406\u65f6\uff0c\u5b9e\u9645\u4e0a\u5c31\u5df2\u7ecf\u4f7f\u7528\u5230\u7ebf\u7a0b\u6c60\u4e86\uff0c\u6c60\u5316\u6280\u672f\u7684\u597d\u5904\uff0c\u6211\u60f3\u5e94\u8be5\u4e0d\u7528\u518d\u8fc7\u591a\u9610\u8ff0\u4e86\uff0c\u4f46\u5173\u4e8e\u7ebf\u7a0b\u6c60\u7684\u4f7f\u7528\u8fd8\u662f\u6709\u5f88\u591a\u6ce8\u610f\u70b9\u7684\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u4f7f\u7528\u573a\u666f<\/h3>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u5f02\u6b65\u4efb\u52a1<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7b80\u5355\u6765\u8bf4\u5c31\u662f\u67d0\u4e9b\u4e0d\u9700\u8981\u540c\u6b65\u8fd4\u56de\u4e1a\u52a1\u5904\u7406\u7ed3\u679c\u7684\u573a\u666f\uff0c\u6bd4\u5982\uff1a\u77ed\u4fe1\u3001\u90ae\u4ef6\u7b49\u901a\u77e5\u7c7b\u4e1a\u52a1\uff0c\u8bc4\u8bba\u3001\u70b9\u8d5e\u7b49\u4e92\u52a8\u6027\u4e1a\u52a1\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u5e76\u884c\u8ba1\u7b97<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5c31\u50cf<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MapReduce<\/code>\u4e00\u6837\uff0c\u5145\u5206\u5229\u7528\u591a\u7ebf\u7a0b\u7684\u5e76\u884c\u8ba1\u7b97\u80fd\u529b\uff0c\u5c06\u5927\u4efb\u52a1\u62c6\u5206\u4e3a\u591a\u4e2a\u5b50\u4efb\u52a1\uff0c\u6700\u540e\u518d\u5c06\u6240\u6709\u5b50\u4efb\u52a1\u8ba1\u7b97\u540e\u7684\u7ed3\u679c\u8fdb\u884c\u6c47\u603b\uff0c<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ForkJoinPool<\/code>\u5c31\u662f JDK \u4e2d\u5178\u578b\u7684\u5e76\u884c\u8ba1\u7b97\u6846\u67b6\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u540c\u6b65\u4efb\u52a1<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u524d\u9762\u8bb2\u5230\u7684<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u4f7f\u7528\uff0c\u5c31\u662f\u5178\u578b\u7684\u540c\u6b65\u6539\u5f02\u6b65\u7684\u65b9\u5f0f\uff0c\u5982\u679c\u4efb\u52a1\u4e4b\u95f4\u6ca1\u6709\u4f9d\u8d56\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u5229\u7528\u7ebf\u7a0b\uff0c\u540c\u65f6\u8fdb\u884c\u5904\u7406\uff0c\u8fd9\u6837\u7406\u8bba\u4e0a\u5c31\u53ea\u9700\u8981\u7b49\u5f85\u8017\u65f6\u6700\u957f\u7684\u6b65\u9aa4\u7ed3\u675f\u5373\u53ef\uff08\u5b9e\u9645\u60c5\u51b5\u53ef\u53c2\u8003<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CompletableFuture<\/code>\u5206\u6790\uff09\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7ebf\u7a0b\u6c60\u7684\u521b\u5efa<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e0d\u8981\u76f4\u63a5\u4f7f\u7528<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">Executors<\/code>\u521b\u5efa\u7ebf\u7a0b\u6c60\uff0c\u5e94\u901a\u8fc7<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ThreadPoolExecutor<\/code>\u7684\u65b9\u5f0f\uff0c\u4e3b\u52a8\u660e\u786e\u7ebf\u7a0b\u6c60\u7684\u53c2\u6570\uff0c\u907f\u514d\u4ea7\u751f\u610f\u5916\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6bcf\u4e2a\u53c2\u6570\u90fd\u8981\u663e\u793a\u8bbe\u7f6e\uff0c\u4f8b\u5982\u50cf\u4e0b\u9762\u8fd9\u6837\uff1a<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">ExecutorService<\/span><span style=\"color: rgb(209, 154, 102);\">executor<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadPoolExecutor<\/span>(<span style=\"color: rgb(209, 154, 102);\">2<\/span>,<span style=\"color: rgb(209, 154, 102);\">4<\/span>,<span style=\"color: rgb(209, 154, 102);\">1L<\/span>,TimeUnit.MINUTES,<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">LinkedBlockingQueue<\/span>&lt;&gt;(<span style=\"color: rgb(209, 154, 102);\">100<\/span>),<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadFactoryBuilder<\/span>().setNameFormat(<span style=\"color: rgb(152, 195, 121);\">\"common-pool-%d\"<\/span>).build(),<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadPoolExecutor<\/span>.CallerRunsPolicy());<\/code><\/pre>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u53c2\u6570\u7684\u914d\u7f6e\u5efa\u8bae<\/h3>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">CorePoolSize\uff08\u6838\u5fc3\u7ebf\u7a0b\u6570\uff09<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e00\u822c\u5728\u914d\u7f6e\u6838\u5fc3\u7ebf\u7a0b\u6570\u7684\u65f6\u5019\uff0c\u662f\u9700\u8981\u7ed3\u5408\u7ebf\u7a0b\u6c60\u5c06\u8981\u5904\u7406\u4efb\u52a1\u7684\u7279\u6027\u6765\u51b3\u5b9a\u7684\uff0c\u800c\u4efb\u52a1\u7684\u6027\u8d28\u4e00\u822c\u53ef\u4ee5\u5212\u5206\u4e3a\uff1aCPU \u5bc6\u96c6\u578b\u3001I\/O \u5bc6\u96c6\u578b\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6bd4\u8f83\u901a\u7528\u7684\u914d\u7f6e\u65b9\u5f0f\u5982\u4e0b<\/p>\n<ul style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">CPU \u5bc6\u96c6\u578b\uff1a<\/strong>\u4e00\u822c\u5efa\u8bae\u7ebf\u7a0b\u7684\u6838\u5fc3\u6570\u4e0e CPU \u6838\u5fc3\u6570\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022<strong style=\"line-height: 1.75;color: rgb(250, 81, 81);\">I\/O \u5bc6\u96c6\u578b\uff1a<\/strong>\u4e00\u822c\u53ef\u4ee5\u8bbe\u7f6e 2 \u500d\u7684 CPU \u6838\u5fc3\u6570\u7684\u7ebf\u7a0b\u6570\uff0c\u56e0\u4e3a\u6b64\u7c7b\u4efb\u52a1 CPU \u6bd4\u8f83\u7a7a\u95f2\uff0c\u53ef\u4ee5\u591a\u5206\u914d\u70b9\u7ebf\u7a0b\u5145\u5206\u5229\u7528 CPU \u8d44\u6e90\u6765\u63d0\u9ad8\u6548\u7387\u3002<\/p>\n<\/li>\n<\/ul>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u901a\u8fc7<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">Runtime.getRuntime().availableProcessors()<\/code>\u53ef\u4ee5\u83b7\u53d6\u6838\u5fc3\u7ebf\u7a0b\u6570\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u53e6\u5916\u8fd8\u6709\u4e00\u4e2a\u516c\u5f0f\u53ef\u4ee5\u501f\u9274<\/p>\n<ul style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022\u7ebf\u7a0b\u6838\u5fc3\u6570 = cpu \u6838\u5fc3\u6570 \/ \uff081-\u963b\u585e\u7cfb\u6570\uff09<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022\u963b\u585e\u7cfb\u6570 = \u963b\u585e\u65f6\u95f4\uff0f\uff08\u963b\u585e\u65f6\u95f4+\u4f7f\u7528 CPU \u7684\u65f6\u95f4\uff09<\/p>\n<\/li>\n<\/ul>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5b9e\u9645\u4e0a\u5927\u591a\u6570\u7ebf\u4e0a\u4e1a\u52a1\u6240\u6d88\u8017\u7684\u65f6\u95f4\u4e3b\u8981\u5c31\u662f I\/O \u7b49\u5f85\uff0c\u56e0\u6b64\u4e00\u822c\u7ebf\u7a0b\u6570\u90fd\u53ef\u4ee5\u8bbe\u7f6e\u7684\u591a\u4e00\u70b9\uff0c\u6bd4\u5982 tomcat \u4e2d\u9ed8\u8ba4\u7684\u7ebf\u7a0b\u6570\u5c31\u662f 200\uff0c\u6240\u4ee5\u6700\u4f73\u7684\u6838\u5fc3\u7ebf\u7a0b\u6570\u662f\u9700\u8981\u6839\u636e\u7279\u5b9a\u573a\u666f\uff0c\u7136\u540e\u901a\u8fc7\u5b9e\u9645\u4e0a\u7ebf\u4e0a\u5141\u8bb8\u7ed3\u679c\u5206\u6790\u540e\uff0c\u518d\u4e0d\u65ad\u7684\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">MaximumPoolSize<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">maximumPoolSize<\/code>\u7684\u8bbe\u7f6e\u4e5f\u662f\u770b\u5b9e\u9645\u5e94\u7528\u573a\u666f\uff0c\u5982\u679c\u8bbe\u7f6e\u7684\u548c<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">corePoolSize<\/code>\u4e00\u6837\uff0c\u90a3\u5c31\u5b8c\u5168\u4f9d\u9760\u963b\u585e\u961f\u5217\u548c\u62d2\u7edd\u7b56\u7565\u6765\u63a7\u5236\u4efb\u52a1\u7684\u5904\u7406\u60c5\u51b5\uff0c\u5982\u679c\u8bbe\u7f6e\u7684\u6bd4<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">corePoolSize<\/code>\u7a0d\u5fae\u5927\u4e00\u70b9\uff0c\u90a3\u5c31\u53ef\u4ee5\u66f4\u597d\u7684\u5e94\u5bf9\u4e00\u4e9b\u6709\u7a81\u53d1\u6d41\u91cf\u4ea7\u751f\u7684\u573a\u666f\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">KeepAliveTime<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7531<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">maximumPoolSize<\/code>\u521b\u5efa\u51fa\u6765\u7684\u7ebf\u7a0b\uff0c\u5728\u7ecf\u8fc7<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">keepAliveTime<\/code>\u65f6\u95f4\u540e\u8fdb\u884c\u9500\u6bc1\uff0c\u4f9d\u636e\u7a81\u53d1\u6d41\u91cf\u6301\u7eed\u7684\u65f6\u95f4\u6765\u51b3\u5b9a\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">WorkQueue<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u90a3\u4e48\u963b\u585e\u961f\u5217\u5e94\u8be5\u8bbe\u7f6e\u591a\u5927\u5462\uff1f\u6211\u4eec\u77e5\u9053\u5f53\u7ebf\u7a0b\u6c60\u4e2d\u6240\u6709\u7684\u7ebf\u7a0b\u90fd\u5728\u5de5\u4f5c\u65f6\uff0c\u5982\u679c\u518d\u6709\u4efb\u52a1\u8fdb\u6765\uff0c\u5c31\u4f1a\u88ab\u653e\u5230\u963b\u585e\u961f\u5217\u4e2d\u7b49\u5f85\uff0c\u5982\u679c\u963b\u585e\u961f\u5217\u8bbe\u7f6e\u7684\u592a\u5c0f\uff0c\u53ef\u80fd\u5f88\u5feb\u961f\u5217\u5c31\u6ee1\u4e86\uff0c\u5bfc\u81f4\u4efb\u52a1\u88ab\u4e22\u5f03\u6216\u8005\u5f02\u5e38\uff08\u7531\u62d2\u7edd\u7b56\u7565\u51b3\u5b9a\uff09\uff0c\u5982\u679c\u961f\u5217\u8bbe\u7f6e\u7684\u592a\u5927\uff0c\u53c8\u53ef\u80fd\u4f1a\u5e26\u6765\u5185\u5b58\u8d44\u6e90\u7684\u7d27\u5f20\uff0c\u751a\u81f3 OOM\uff0c\u4ee5\u53ca\u4efb\u52a1\u5ef6\u8fdf\u65f6\u95f4\u8fc7\u957f\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6240\u4ee5\u963b\u585e\u961f\u5217\u7684\u5927\u5c0f\uff0c\u53c8\u662f\u8981\u7ed3\u5408\u5b9e\u9645\u573a\u666f\u6765\u8bbe\u7f6e\u7684\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e00\u822c\u4f1a\u6839\u636e\u5904\u7406\u4efb\u52a1\u7684\u901f\u5ea6\u4e0e\u4efb\u52a1\u4ea7\u751f\u7684\u901f\u5ea6\u8fdb\u884c\u8ba1\u7b97\u5f97\u5230\u4e00\u4e2a\u5927\u6982\u7684\u6570\u503c\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5047\u8bbe\u73b0\u5728\u6709 1 \u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u79d2\u949f\u53ef\u4ee5\u5904\u7406 10 \u4e2a\u4efb\u52a1\uff0c\u6b63\u5e38\u60c5\u51b5\u4e0b\u6bcf\u79d2\u949f\u4ea7\u751f\u7684\u4efb\u52a1\u6570\u5c0f\u4e8e 10\uff0c\u90a3\u4e48\u6b64\u65f6\u961f\u5217\u957f\u5ea6\u4e3a 10 \u5c31\u8db3\u4ee5\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f46\u662f\u5982\u679c\u9ad8\u5cf0\u65f6\u671f\uff0c\u6bcf\u79d2\u4ea7\u751f\u7684\u4efb\u52a1\u6570\u4f1a\u8fbe\u5230 20\uff0c\u4f1a\u6301\u7eed 10 \u79d2\uff0c\u4e14\u4efb\u52a1\u53c8\u4e0d\u5e0c\u671b\u4e22\u5f03\uff0c\u90a3\u4e48\u6b64\u65f6\u961f\u5217\u7684\u957f\u5ea6\u5c31\u9700\u8981\u8bbe\u7f6e\u5230 100\u3002<\/p>\n<blockquote style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;border-left: none;padding: 1em;border-radius: 8px;color: rgba(0, 0, 0, 0.5);background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u76d1\u63a7 workQueue \u4e2d\u7b49\u5f85\u4efb\u52a1\u7684\u6570\u91cf\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u53ea\u6709\u4e86\u89e3\u5b9e\u9645\u7684\u60c5\u51b5\uff0c\u624d\u80fd\u505a\u51fa\u6b63\u786e\u7684\u51b3\u5b9a\u3002<\/p>\n<\/blockquote>\n<blockquote style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;border-left: none;padding: 1em;border-radius: 8px;color: rgba(0, 0, 0, 0.5);background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u5728\u6709\u4e9b\u573a\u666f\u4e2d\uff0c\u53ef\u80fd\u5e76\u4e0d\u5e0c\u671b\u56e0\u4e3a\u4efb\u52a1\u88ab\u4e22\u8fdb\u963b\u585e\u961f\u5217\u800c\u7b49\u5f85\u592a\u957f\u7684\u65f6\u95f4\uff0c\u800c\u662f\u5e0c\u671b\u76f4\u63a5\u5f00\u542f\u8bbe\u7f6e\u7684<code style=\"line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">MaximumPoolSize<\/code>\u7ebf\u7a0b\u6c60\u6570\u6765\u6267\u884c\u4efb\u52a1\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e0b\u4e00\u822c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<code style=\"line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">SynchronousQueue<\/code>\u961f\u5217\u6765\u5b9e\u73b0<\/p>\n<\/blockquote>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">ThreadFactory<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u901a\u8fc7 threadFactory \u6211\u4eec\u53ef\u4ee5\u81ea\u5b9a\u4e49\u7ebf\u7a0b\u7ec4\u7684\u540d\u5b57\uff0c\u8bbe\u7f6e\u5408\u7406\u7684\u540d\u79f0\u5c06\u6709\u5229\u4e8e\u4f60\u7ebf\u4e0a\u8fdb\u884c\u95ee\u9898\u6392\u67e5\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">Handler<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6700\u540e\u62d2\u7edd\u7b56\u7565\uff0c\u8fd9\u4e5f\u662f\u8981\u7ed3\u5408\u5b9e\u9645\u7684\u4e1a\u52a1\u573a\u666f\u6765\u51b3\u5b9a\u91c7\u7528\u4ec0\u4e48\u6837\u7684\u62d2\u7edd\u65b9\u5f0f\uff0c\u4f8b\u5982\u50cf\u8fc7\u7a0b\u7c7b\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u76f4\u63a5\u91c7\u7528<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">DiscardOldestPolicy<\/code>\u7b56\u7565\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7ebf\u7a0b\u6c60\u7684\u76d1\u63a7<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7ebf\u4e0a\u4f7f\u7528\u7ebf\u7a0b\u6c60\u65f6\uff0c\u4e00\u5b9a\u8981\u505a\u597d\u76d1\u63a7\uff0c\u4ee5\u4fbf\u6839\u636e\u5b9e\u9645\u8fd0\u884c\u60c5\u51b5\u8fdb\u884c\u8c03\u6574\uff0c\u5e38\u89c1\u7684\u76d1\u63a7\u65b9\u5f0f\u53ef\u4ee5\u901a\u8fc7\u7ebf\u7a0b\u6c60\u63d0\u4f9b\u7684 API\uff0c\u7136\u540e\u66b4\u9732\u7ed9 Metrics \u6765\u5b8c\u6210\u5b9e\u65f6\u6570\u636e\u7edf\u8ba1\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u76d1\u63a7\u793a\u4f8b<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7ebf\u7a0b\u6c60\u81ea\u8eab\u63d0\u4f9b\u7684\u7edf\u8ba1\u6570\u636e<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadPoolMonitor<\/span>{<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(209, 154, 102);\">Logger<\/span><span style=\"color: rgb(209, 154, 102);\">log<\/span>=LoggerFactory.getLogger(ThreadPoolMonitor.class);<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">ThreadPoolExecutor<\/span><span style=\"color: rgb(209, 154, 102);\">threadPool<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadPoolExecutor<\/span>(<span style=\"color: rgb(209, 154, 102);\">2<\/span>,<span style=\"color: rgb(209, 154, 102);\">4<\/span>,<span style=\"color: rgb(209, 154, 102);\">0<\/span>,TimeUnit.SECONDS,<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">LinkedBlockingQueue<\/span>&lt;&gt;(<span style=\"color: rgb(209, 154, 102);\">100<\/span>),<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadFactoryBuilder<\/span>().setNameFormat(<span style=\"color: rgb(152, 195, 121);\">\"my_thread_pool_%d\"<\/span>).build());<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args){log.info(<span style=\"color: rgb(152, 195, 121);\">\"PoolSize:\"<\/span>+threadPool.getPoolSize());log.info(<span style=\"color: rgb(152, 195, 121);\">\"ActiveThreadCount:\"<\/span>+threadPool.getActiveCount());log.info(<span style=\"color: rgb(152, 195, 121);\">\"TaskQueueSize:\"<\/span>+threadPool.getQueue().size());log.info(<span style=\"color: rgb(152, 195, 121);\">\"CompletedTaskCount:\"<\/span>+threadPool.getCompletedTaskCount());}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u901a\u8fc7 micrometer API \u5b8c\u6210\u7edf\u8ba1\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u63a5\u5165<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">Prometheus<\/code>\u4e86<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">package<\/span>com.springboot.micrometer.monitor;<span style=\"color: rgb(198, 120, 221);\">import<\/span>com.google.common.util.concurrent.ThreadFactoryBuilder;<span style=\"color: rgb(198, 120, 221);\">import<\/span>io.micrometer.core.instrument.Metrics;<span style=\"color: rgb(198, 120, 221);\">import<\/span>org.springframework.stereotype.Component;<span style=\"color: rgb(198, 120, 221);\">import<\/span>javax.annotation.PostConstruct;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.Executors;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.LinkedBlockingQueue;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.ThreadPoolExecutor;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.TimeUnit;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.atomic.AtomicLong;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.stream.IntStream;<span style=\"color: rgb(97, 174, 238);\">@Component<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadPoolMonitor<\/span>{<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">ThreadPoolExecutor<\/span><span style=\"color: rgb(209, 154, 102);\">threadPool<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadPoolExecutor<\/span>(<span style=\"color: rgb(209, 154, 102);\">4<\/span>,<span style=\"color: rgb(209, 154, 102);\">8<\/span>,<span style=\"color: rgb(209, 154, 102);\">0<\/span>,TimeUnit.SECONDS,<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">LinkedBlockingQueue<\/span>&lt;&gt;(<span style=\"color: rgb(209, 154, 102);\">100<\/span>),<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadFactoryBuilder<\/span>().setNameFormat(<span style=\"color: rgb(152, 195, 121);\">\"my_thread_pool_%d\"<\/span>).build(),<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadPoolExecutor<\/span>.DiscardOldestPolicy());<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u6d3b\u8dc3\u7ebf\u7a0b\u6570*\/<\/span><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(209, 154, 102);\">AtomicLong<\/span><span style=\"color: rgb(209, 154, 102);\">activeThreadCount<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">AtomicLong<\/span>(<span style=\"color: rgb(209, 154, 102);\">0<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u961f\u5217\u4efb\u52a1\u6570*\/<\/span><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(209, 154, 102);\">AtomicLong<\/span><span style=\"color: rgb(209, 154, 102);\">taskQueueSize<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">AtomicLong<\/span>(<span style=\"color: rgb(209, 154, 102);\">0<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u5b8c\u6210\u4efb\u52a1\u6570*\/<\/span><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(209, 154, 102);\">AtomicLong<\/span><span style=\"color: rgb(209, 154, 102);\">completedTaskCount<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">AtomicLong<\/span>(<span style=\"color: rgb(209, 154, 102);\">0<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u7ebf\u7a0b\u6c60\u4e2d\u5f53\u524d\u7ebf\u7a0b\u7684\u6570\u91cf*\/<\/span><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(209, 154, 102);\">AtomicLong<\/span><span style=\"color: rgb(209, 154, 102);\">poolSize<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">AtomicLong<\/span>(<span style=\"color: rgb(209, 154, 102);\">0<\/span>);<span style=\"color: rgb(97, 174, 238);\">@PostConstruct<\/span><span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">init<\/span>(){<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u901a\u8fc7micrometerAPI\u5b8c\u6210\u7edf\u8ba1** gauge\u6700\u5178\u578b\u7684\u4f7f\u7528\u573a\u666f\u5c31\u662f\u7edf\u8ba1\uff1alist\u3001Map\u3001\u7ebf\u7a0b\u6c60\u3001\u8fde\u63a5\u6c60\u7b49\u96c6\u5408\u7c7b\u578b\u7684\u6570\u636e*\/<\/span>Metrics.gauge(<span style=\"color: rgb(152, 195, 121);\">\"my_thread_pool_active_thread_count\"<\/span>,activeThreadCount);Metrics.gauge(<span style=\"color: rgb(152, 195, 121);\">\"my_thread_pool_task_queue_size\"<\/span>,taskQueueSize);Metrics.gauge(<span style=\"color: rgb(152, 195, 121);\">\"my_thread_pool_completed_task_count\"<\/span>,completedTaskCount);Metrics.gauge(<span style=\"color: rgb(152, 195, 121);\">\"my_thread_pool_size\"<\/span>,poolSize);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u6a21\u62df\u7ebf\u7a0b\u6c60\u7684\u4f7f\u7528<\/span><span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(<span style=\"color: rgb(230, 192, 123);\">this<\/span>::runTask).start();}<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">runTask<\/span>(){<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u6bcf5\u79d2\u76d1\u63a7\u4e00\u6b21\u7ebf\u7a0b\u6c60\u7684\u4f7f\u7528\u60c5\u51b5<\/span>monitorThreadPoolState();<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u6a21\u62df\u4efb\u52a1\u6267\u884c<\/span>IntStream.rangeClosed(<span style=\"color: rgb(209, 154, 102);\">0<\/span>,<span style=\"color: rgb(209, 154, 102);\">500<\/span>).forEach(i-&gt;{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u6bcf500\u6beb\u79d2\uff0c\u6267\u884c\u4e00\u4e2a\u4efb\u52a1<\/span><span style=\"color: rgb(198, 120, 221);\">try<\/span>{TimeUnit.MILLISECONDS.sleep(<span style=\"color: rgb(209, 154, 102);\">500<\/span>);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u6bcf\u4e2a\u5904\u7406\u4e00\u4e2a\u4efb\u52a1\u8017\u65f65\u79d2<\/span>threadPool.submit(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">try<\/span>{TimeUnit.MILLISECONDS.sleep(<span style=\"color: rgb(209, 154, 102);\">5000<\/span>);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}});});}<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">monitorThreadPoolState<\/span>(){Executors.newSingleThreadScheduledExecutor().scheduleAtFixedRate(()-&gt;{activeThreadCount.set(threadPool.getActiveCount());taskQueueSize.set(threadPool.getQueue().size());poolSize.set(threadPool.getPoolSize());completedTaskCount.set(threadPool.getCompletedTaskCount());},<span style=\"color: rgb(209, 154, 102);\">0<\/span>,<span style=\"color: rgb(209, 154, 102);\">5<\/span>,TimeUnit.SECONDS);}}<\/code><\/pre>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7ebf\u7a0b\u6c60\u7684\u8d44\u6e90\u9694\u79bb<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u751f\u4ea7\u73af\u5883\u4e2d\uff0c\u4e00\u5b9a\u8981\u6ce8\u610f\u597d\u8d44\u6e90\u9694\u79bb\u7684\u95ee\u9898\uff0c\u5c3d\u91cf\u4e0d\u8981\u5c06\u4e0d\u540c\u7c7b\u578b\uff0c\u4e0d\u540c\u91cd\u8981\u7b49\u7ea7\u7684\u4efb\u52a1\u653e\u5165\u4e00\u4e2a\u7ebf\u7a0b\u6c60\u4e2d\uff0c\u4ee5\u514d\u56e0\u4e3a\u7ebf\u7a0b\u8d44\u6e90\u4e89\u62a2\u800c\u4e92\u76f8\u5f71\u54cd\u3002<\/p>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">5. \u670d\u52a1\u9884\u70ed<\/h1>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u670d\u52a1\u9884\u70ed\u4e5f\u662f\u5f88\u5e38\u89c1\u7684\u4e00\u79cd\u4f18\u5316\u624b\u6bb5\uff0c\u4f8b\u5982\u6570\u636e\u5e93\u8fde\u63a5\u3001\u7ebf\u7a0b\u6c60\u4e2d\u7684\u6838\u5fc3\u7ebf\u7a0b\uff0c\u7f13\u5b58\u7b49\u4fe1\u606f\u53ef\u4ee5\u5229\u7528\u670d\u52a1\u542f\u52a8\u9636\u6bb5\u9884\u5148\u52a0\u8f7d\uff0c\u4ece\u800c\u907f\u514d\u8bf7\u6c42\u5230\u6765\u540e\u4e34\u65f6\u6784\u5efa\u7684\u8017\u65f6\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e0b\u9762\u63d0\u4f9b\u4e00\u4e9b\u9884\u52a0\u8f7d\u7684\u65b9\u5f0f<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7ebf\u7a0b\u6c60<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7ebf\u7a0b\u6c60\u672c\u8eab\u63d0\u4f9b\u4e86\u76f8\u5173\u7684 API\uff1a<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">prestartAllCoreThreads()<\/code>\u901a\u8fc7\u8be5\u65b9\u6cd5\u53ef\u4ee5\u63d0\u524d\u5c06\u6838\u5fc3\u7ebf\u7a0b\u521b\u5efa\u597d\uff0c\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">Web \u670d\u52a1<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5e38\u89c1\u7684\u5982 Tomcat\uff0c\u5176\u672c\u8eab\u4e5f\u7528\u5230\u4e86\u7ebf\u7a0b\u6c60\uff0c\u53ea\u662f\u5176\u81ea\u8eab\u5df2\u7ecf\u8003\u8651\u5230\u4e86\u9884\u52a0\u8f7d\u7684\u95ee\u9898\uff0c\u4e0d\u9700\u8981\u6211\u4eec\u989d\u5916\u5904\u7406\u4e86\u3002<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100036995\" data-ratio=\"0.3175925925925926\" data-type=\"other\" data-w=\"1080\"  style=\"line-height: 1.75;border-radius: 4px;display: block;margin: 0.1em auto 0.5em;height: auto !important;\" title=\"null\" src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100036995\" data-ratio=\"0.3175925925925926\" data-type=\"other\" data-w=\"1080\"  style=\"line-height: 1.75;border-radius: 4px;display: block;margin: 0.1em auto 0.5em;height: auto !important;\" title=\"null\" src=\"\"  \/><\/noscript><\/figure>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u8fde\u63a5\u6c60<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u8fde\u63a5\u6c60\u5e38\u7528\u7684\u4e00\u822c\u5c31\u662f\u6570\u636e\u5e93\u8fde\u63a5\u6c60\u4ee5\u53caRedis\u8fde\u63a5\u6c60\uff0c\u5927\u591a\u6570\u8fd9\u4e9b\u8fde\u63a5\u7684\u5ba2\u6237\u7aef\u4e5f\u90fd\u505a\u4e86\u8fde\u63a5\u63d0\u524d\u52a0\u8f7d\u7684\u5de5\u4f5c\uff0c\u9047\u5230\u6ca1\u6709\u9884\u52a0\u8f7d\u7684\u53c2\u8003\u5176\u4ed6\u5ba2\u6237\u7aef\u65b9\u5f0f\u641e\u4e00\u4e0b\u5373\u53ef\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7f13\u5b58<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e00\u822c\u672c\u5730\u7f13\u5b58\u53ef\u4ee5\u5728\u6bcf\u6b21\u670d\u52a1\u542f\u52a8\u65f6\u9884\u5148\u52a0\u8f7d\u597d\uff0c\u4ee5\u514d\u51fa\u73b0\u7f13\u5b58\u51fb\u7a7f\u7684\u60c5\u51b5\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u9759\u6001\u4ee3\u7801\u5757<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u670d\u52a1\u542f\u52a8\u65f6\uff0c\u9759\u6001\u4ee3\u7801\u5757\u4e2d\u7684\u76f8\u5173\u529f\u80fd\u4f1a\u4f18\u5148\u88ab\u52a0\u8f7d\uff0c\u53ef\u4ee5\u6709\u6548\u907f\u514d\u5728\u8fd0\u884c\u65f6\u518d\u52a0\u8f7d\u7684\u60c5\u51b5\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u5176\u4ed6\u6269\u5c55<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u9884\u70ed\u5b9e\u9645\u4e0a\u53ef\u804a\u7684\u5185\u5bb9\u5f88\u591a\uff0c\u4e00\u822c\u6709\u7528\u5230\u6c60\u5316\u6280\u672f\u7684\u65b9\u5f0f\uff0c\u90fd\u662f\u9700\u8981\u9884\u70ed\u7684\uff0c\u4e3a\u4e86\u80fd\u591f\u63d0\u5347\u54cd\u5e94\u6027\u80fd\uff0c\u5c06\u4e0d\u5728\u5185\u5b58\u4e2d\u7684\u6570\u636e\u63d0\u524d\u67e5\u597d\u653e\u5165\u5185\u5b58\u4e2d\uff0c\u6216\u8005\u5c06\u9700\u8981\u8ba1\u7b97\u7684\u6570\u636e\u63d0\u524d\u8ba1\u7b97\u597d\uff0c\u8fd9\u90fd\u662f\u5f88\u5bb9\u6613\u60f3\u5230\u7684\u89e3\u51b3\u65b9\u5f0f\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6b64\u5916\u8fd8\u6709\u4e00\u4e9b\u670d\u52a1\u7aef\u5728\u8bbe\u8ba1\u4e4b\u521d\u5c31\u4f1a\u9488\u5bf9\u6027\u5730\u5bf9\u4e00\u4e9b\u70ed\u70b9\u6570\u636e\u8fdb\u884c\u7279\u6b8a\u5904\u7406\uff0c\u6bd4\u5982JVM\u4e2d\u7684JIT\u3001\u5185\u5b58\u5206\u914d\u6bd4\uff1bOS\u4e2d\u7684<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">pagecache<\/code>\uff1bMySQL\u4e2d\u7684<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">innodb_buffer_pool<\/code>\u7b49\uff0c\u8fd9\u4e9b\u4e00\u822c\u53ef\u4ee5\u901a\u8fc7\u6d41\u91cf\u9884\u70ed\u7684\u65b9\u5f0f\u6765\u4f7f\u5176\u8fbe\u5230\u6700\u4f73\u72b6\u6001\u3002<\/p>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">6. \u7f13\u5b58\u5bf9\u9f50<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">CPU\u7684\u591a\u7ea7\u7f13\u5b58<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">CPU\u7f13\u5b58\u901a\u5e38\u5206\u4e3a\u5927\u5c0f\u4e0d\u7b49\u7684\u4e09\u7ea7\u7f13\u5b58<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6765\u81ea\u767e\u5ea6\u767e\u79d1\u5bf9\u4e09\u7ea7\u7f13\u5b58\u5206\u7c7b\u7684\u4ecb\u7ecd\uff1a<\/p>\n<blockquote style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;border-left: none;padding: 1em;border-radius: 8px;color: rgba(0, 0, 0, 0.5);background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u4e00\u7ea7\u7f13\u5b58\u90fd\u5185\u7f6e\u5728CPU\u5185\u90e8\u5e76\u4e0eCPU\u540c\u901f\u8fd0\u884c\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u63d0\u9ad8CPU\u7684\u8fd0\u884c\u6548\u7387\u3002\u4e00\u7ea7\u7f13\u5b58\u8d8a\u5927\uff0cCPU\u7684\u8fd0\u884c\u6548\u7387\u8d8a\u9ad8\uff0c\u4f46\u53d7\u5230CPU\u5185\u90e8\u7ed3\u6784\u7684\u9650\u5236\uff0c\u4e00\u7ea7\u7f13\u5b58\u7684\u5bb9\u91cf\u90fd\u5f88\u5c0f\u3002<\/p>\n<\/blockquote>\n<blockquote style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;border-left: none;padding: 1em;border-radius: 8px;color: rgba(0, 0, 0, 0.5);background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u4e8c\u7ea7\u7f13\u5b58\uff0c\u5b83\u662f\u4e3a\u4e86\u534f\u8c03\u4e00\u7ea7\u7f13\u5b58\u548c\u5185\u5b58\u4e4b\u95f4\u7684\u901f\u5ea6\u3002cpu\u8c03\u7528\u7f13\u5b58\u9996\u5148\u662f\u4e00\u7ea7\u7f13\u5b58\uff0c\u5f53\u5904\u7406\u5668\u7684\u901f\u5ea6\u9010\u6e10\u63d0\u5347\uff0c\u4f1a\u5bfc\u81f4\u4e00\u7ea7\u7f13\u5b58\u5c31\u4f9b\u4e0d\u5e94\u6c42\uff0c\u8fd9\u6837\u5c31\u5f97\u63d0\u5347\u5230\u4e8c\u7ea7\u7f13\u5b58\u4e86\u3002\u4e8c\u7ea7\u7f13\u5b58\u5b83\u6bd4\u4e00\u7ea7\u7f13\u5b58\u7684\u901f\u5ea6\u76f8\u5bf9\u6765\u8bf4\u4f1a\u6162\uff0c\u4f46\u662f\u5b83\u6bd4\u4e00\u7ea7\u7f13\u5b58\u7684\u7a7a\u95f4\u5bb9\u91cf\u8981\u5927\u3002\u4e3b\u8981\u5c31\u662f\u505a\u4e00\u7ea7\u7f13\u5b58\u548c\u5185\u5b58\u4e4b\u95f4\u6570\u636e\u4e34\u65f6\u4ea4\u6362\u7684\u5730\u65b9\u7528\u3002<\/p>\n<\/blockquote>\n<blockquote style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;border-left: none;padding: 1em;border-radius: 8px;color: rgba(0, 0, 0, 0.5);background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u4e09\u7ea7\u7f13\u5b58\u662f\u4e3a\u8bfb\u53d6\u4e8c\u7ea7\u7f13\u5b58\u540e\u672a\u547d\u4e2d\u7684\u6570\u636e\u8bbe\u8ba1\u7684\u2014\u79cd\u7f13\u5b58\uff0c\u5728\u62e5\u6709\u4e09\u7ea7\u7f13\u5b58\u7684CPU\u4e2d\uff0c\u53ea\u6709\u7ea65%\u7684\u6570\u636e\u9700\u8981\u4ece\u5185\u5b58\u4e2d\u8c03\u7528\uff0c\u8fd9\u8fdb\u4e00\u6b65\u63d0\u9ad8\u4e86CPU\u7684\u6548\u7387\u3002\u5176\u8fd0\u4f5c\u539f\u7406\u5728\u4e8e\u4f7f\u7528\u8f83\u5feb\u901f\u7684\u50a8\u5b58\u88c5\u7f6e\u4fdd\u7559\u4e00\u4efd\u4ece\u6162\u901f\u50a8\u5b58\u88c5\u7f6e\u4e2d\u6240\u8bfb\u53d6\u6570\u636e\u5e76\u8fdb\u884c\u62f7\u8d1d\uff0c\u5f53\u6709\u9700\u8981\u518d\u4ece\u8f83\u6162\u7684\u50a8\u5b58\u4f53\u4e2d\u8bfb\u5199\u6570\u636e\u65f6\uff0c\u7f13\u5b58(cache)\u80fd\u591f\u4f7f\u5f97\u8bfb\u5199\u7684\u52a8\u4f5c\u5148\u5728\u5feb\u901f\u7684\u88c5\u7f6e\u4e0a\u5b8c\u6210\uff0c\u5982\u6b64\u4f1a\u4f7f\u7cfb\u7edf\u7684\u54cd\u5e94\u8f83\u4e3a\u5feb\u901f\u3002<\/p>\n<\/blockquote>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u6548\u679c\u6f14\u793a<\/h3>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u9010\u884c\u5199\u5165<\/h4>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">CacheLine<\/span>{<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args){<span style=\"color: rgb(209, 154, 102);\">int<\/span>[][]arr=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">int<\/span>[<span style=\"color: rgb(209, 154, 102);\">10000<\/span>][<span style=\"color: rgb(209, 154, 102);\">10000<\/span>];<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">s<\/span>=System.currentTimeMillis();<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;arr.length;i++){<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">j<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;j&lt;arr[i].length;j++){arr[i][j]=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;}}<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e<\/span>=System.currentTimeMillis();System.out.println(e-s);}}<\/code><\/pre>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u9010\u5217\u5199\u5165<\/h4>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">CacheLine<\/span>{<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args){<span style=\"color: rgb(209, 154, 102);\">int<\/span>[][]arr=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">int<\/span>[<span style=\"color: rgb(209, 154, 102);\">10000<\/span>][<span style=\"color: rgb(209, 154, 102);\">10000<\/span>];<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">s<\/span>=System.currentTimeMillis();<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;arr.length;i++){<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">j<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;j&lt;arr[i].length;j++){arr[j][i]=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;}}<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e<\/span>=System.currentTimeMillis();System.out.println(e-s);}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u867d\u7136\u4e24\u79cd\u65b9\u5f0f\u5f97\u5230\u7684\u7ed3\u679c\u662f\u4e00\u6837\u7684\uff0c\u4f46\u6027\u80fd\u5bf9\u6bd4\u5374\u76f8\u5dee\u5de8\u5927\uff0c\u8fd9\u5c31\u662f\u7f13\u5b58\u884c\u5e26\u6765\u7684\u5f71\u54cd\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u539f\u56e0\u5206\u6790<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">CPU\u7684\u7f13\u5b58\u662f\u7531\u591a\u4e2a\u7f13\u5b58\u884c\u7ec4\u6210\u7684\uff0c\u4ee5\u7f13\u5b58\u884c\u4e3a\u57fa\u672c\u5355\u4f4d\uff0c\u4e00\u4e2a\u7f13\u5b58\u884c\u7684\u5927\u5c0f\u4e00\u822c\u4e3a64\u5b57\u8282\uff0c\u4e8c\u7ef4\u6570\u7ec4\u5728\u5185\u5b58\u4e2d\u4fdd\u5b58\u65f6\uff0c\u5b9e\u9645\u4e0a\u662f\u4ee5\u6309\u884c\u904d\u5386\u7684\u65b9\u5f0f\u8fdb\u884c\u4fdd\u5b58\uff0c\u6bd4\u5982:<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">arr[0][0]<\/code>,<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">arr[0][1]<\/code>,<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">arr[1][0]<\/code>,<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">arr[1][1]<\/code>,<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">arr[2][0]<\/code>,<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">arr[2][1]<\/code>...<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6240\u4ee5\u5f53\u6309\u884c\u8bbf\u95ee\u65f6\uff0c\u662f\u6309\u7167\u5185\u5b58\u5b58\u50a8\u7684\u987a\u5e8f\u8fdb\u884c\u8bbf\u95ee\uff0c\u90a3\u4e48CPU\u7f13\u5b58\u540e\u9762\u7684\u5143\u7d20\u5c31\u53ef\u4ee5\u5229\u7528\u5230\uff0c\u800c\u5982\u679c\u662f\u6309\u5217\u8bbf\u95ee\uff0c\u90a3\u4e48CPU\u7684\u7f13\u5b58\u662f\u6ca1\u6709\u7528\u7684\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7f13\u5b58\u884c\u5bf9\u9f50<\/h3>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">CacheLinePadding<\/span>{<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">Padding<\/span>{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u4e00\u4e2along\u662f8\u4e2a\u5b57\u8282\uff0c\u4e00\u51717\u4e2along<\/span><span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/publicvolatilelongp1,p2,p3,p4,p5,p6,p7;<\/span>}<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">T<\/span><span style=\"color: rgb(198, 120, 221);\">extends<\/span><span style=\"color: rgb(230, 192, 123);\">Padding<\/span>{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/ x\u53d8\u91cf8\u4e2a\u5b57\u8282\uff0c\u52a0\u4e0aPadding\u4e2d\u7684\u53d8\u91cf\uff0c\u521a\u597d64\u4e2a\u5b57\u8282\uff0c\u72ec\u5360\u4e00\u4e2a\u7f13\u5b58\u884c\u3002<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">volatile<\/span><span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">x<\/span>=<span style=\"color: rgb(209, 154, 102);\">0L<\/span>;}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span>T[]arr=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">T<\/span>[<span style=\"color: rgb(209, 154, 102);\">2<\/span>];<span style=\"color: rgb(198, 120, 221);\">static<\/span>{arr[<span style=\"color: rgb(209, 154, 102);\">0<\/span>]=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">T<\/span>();arr[<span style=\"color: rgb(209, 154, 102);\">1<\/span>]=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">T<\/span>();}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>Exception{<span style=\"color: rgb(209, 154, 102);\">Thread<\/span><span style=\"color: rgb(209, 154, 102);\">t1<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">10000000<\/span>;i++){arr[<span style=\"color: rgb(209, 154, 102);\">0<\/span>].x=i;}});<span style=\"color: rgb(209, 154, 102);\">Thread<\/span><span style=\"color: rgb(209, 154, 102);\">t2<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">10000000<\/span>;i++){arr[<span style=\"color: rgb(209, 154, 102);\">1<\/span>].x=i;}});<span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">start<\/span>=System.nanoTime();t1.start();t2.start();t1.join();t2.join();System.out.println((System.nanoTime()-start)\/<span style=\"color: rgb(209, 154, 102);\">100000<\/span>);}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u540c\u6837\u7684\u542b\u6709<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">public volatile long p1, p2, p3, p4, p5, p6, p7;<\/code>\u8fd9\u4e00\u884c\u4ee3\u7801\u4e0e\u4e0d\u542b\u6027\u80fd\u4e5f\u76f8\u5dee\u5de8\u5927\uff0c\u8fd9\u540c\u6837\u4e5f\u662f\u56e0\u4e3a\u7f13\u5b58\u884c\u7684\u539f\u56e0\uff0c\u5f53\u8fd0\u884c\u5728\u4e24\u4e2a\u4e0d\u540cCPU\u4e0a\u7684\u4e24\u4e2a\u7ebf\u7a0b\u8981\u5199\u5165\u3002<\/p>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">7. \u51cf\u5c11\u5bf9\u8c61\u7684\u4ea7\u751f<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u907f\u514d\u4f7f\u7528\u5305\u88c5\u7c7b\u578b<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u56e0\u4e3a\u5305\u88c5\u7c7b\u578b\u7684\u521b\u5efa\u548c\u9500\u6bc1\u90fd\u4f1a\u4ea7\u751f\u4e34\u65f6\u5bf9\u8c61\uff0c\u56e0\u6b64\u76f8\u6bd4\u57fa\u672c\u6570\u636e\u7c7b\u578b\u6765\u8bf4\uff0c\u4f1a\u5e26\u6765\u989d\u5916\u7684\u6d88\u8017\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">Main<\/span>{<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args){<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">s<\/span>=System.currentTimeMillis();testInteger();<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e<\/span>=System.currentTimeMillis();System.out.println(e-s);testInt();<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e2<\/span>=System.currentTimeMillis();System.out.println(e2-e);}<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">testInt<\/span>(){<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">sum<\/span>=<span style=\"color: rgb(209, 154, 102);\">1<\/span>;<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">1<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">50000000<\/span>;i++){sum++;}System.out.println(sum);}<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">testInteger<\/span>(){<span style=\"color: rgb(209, 154, 102);\">Integer<\/span><span style=\"color: rgb(209, 154, 102);\">sum<\/span>=<span style=\"color: rgb(209, 154, 102);\">1<\/span>;<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">1<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">50000000<\/span>;i++){sum++;}System.out.println(sum);}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e24\u4e2a\u65b9\u6cd5\u4e0d\u4ec5\u6267\u884c\u65f6\u95f4\u76f8\u5dee\u767e\u500d\uff0c\u5728CPU\u548c\u5185\u5b58\u7684\u6d88\u8017\u4e0aInteger\u4e5f\u660e\u663e\u5f31\u4e8eint\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">Integer\u5185\u5b58\u548cCPU\u90fd\u80fd\u770b\u5230\u660e\u663e\u7684\u6ce2\u52a8<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100036996\" data-ratio=\"0.3425925925925926\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100036996\" data-ratio=\"0.3425925925925926\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><\/noscript><\/figure>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">int\u51e0\u4e4e\u6ca1\u6ce2\u52a8<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100036997\" data-ratio=\"0.30092592592592593\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100036997\" data-ratio=\"0.30092592592592593\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><\/noscript><\/figure>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u4f7f\u7528\u4e0d\u53ef\u53d8\u5bf9\u8c61<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6700\u4e3a\u5178\u578b\u7684\u6848\u4f8b\u5c31\u662fString\uff0c\u6211\u60f3\u5e94\u8be5\u4e0d\u4f1a\u6709\u4eba\u53bb\u901a\u8fc7new\u7684\u65b9\u5f0f\u518d\u53bb\u6784\u5efa\u4e00\u4e2aString\u5b57\u7b26\u4e32\u4e86\u5427\uff01<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(209, 154, 102);\">String<\/span><span style=\"color: rgb(209, 154, 102);\">str<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">String<\/span>(<span style=\"color: rgb(152, 195, 121);\">\"abc\"<\/span>);<span style=\"color: rgb(209, 154, 102);\">String<\/span><span style=\"color: rgb(209, 154, 102);\">str<\/span>=<span style=\"color: rgb(152, 195, 121);\">\"abc\"<\/span>;<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u540c\u65f6\uff0c\u5728\u5b9e\u73b0\u5b57\u7b26\u4e32\u8fde\u63a5\u65f6\u901a\u5e38\u4f7f\u7528StringBuilder\u6216StringBuffer\uff0c\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4f7f\u7528\u8fde\u63a5\u7b26\uff0c\u5bfc\u81f4\u6bcf\u6b21\u90fd\u521b\u5efa\u65b0\u7684\u5b57\u7b26\u4e32\u5bf9\u8c61\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u9759\u6001\u65b9\u6cd5<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u9759\u6001\u5bf9\u8c61<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">Boolean.valueOf(<span style=\"color: rgb(152, 195, 121);\">\"true\"<\/span>);<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span>Boolean<span style=\"color: rgb(97, 174, 238);\">valueOf<\/span>(Strings){<span style=\"color: rgb(198, 120, 221);\">return<\/span>parseBoolean(s)?TRUE:FALSE;}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">Boolean<\/span><span style=\"color: rgb(209, 154, 102);\">TRUE<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Boolean<\/span>(<span style=\"color: rgb(86, 182, 194);\">true<\/span>);<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">Boolean<\/span><span style=\"color: rgb(209, 154, 102);\">FALSE<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Boolean<\/span>(<span style=\"color: rgb(86, 182, 194);\">false<\/span>);<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u9759\u6001\u5de5\u5382\uff08\u5355\u4f8b\u6a21\u5f0f\uff09<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">StaticSingleton<\/span>{<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">StaticHolder<\/span>{<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">StaticSingleton<\/span><span style=\"color: rgb(209, 154, 102);\">INSTANCE<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">StaticSingleton<\/span>();}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span>StaticSingleton<span style=\"color: rgb(97, 174, 238);\">getInstance<\/span>(){<span style=\"color: rgb(198, 120, 221);\">return<\/span>StaticHolder.INSTANCE;}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u679a\u4e3e<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">enum<\/span><span style=\"color: rgb(230, 192, 123);\">EnumSingleton<\/span>{INSTANCE;}<\/code><\/pre>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u89c6\u56fe<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u89c6\u56fe\u662f\u8fd4\u56de\u5f15\u7528\u7684\u4e00\u79cd\u65b9\u5f0f\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">map\u7684keySet\u65b9\u6cd5\uff0c\u5b9e\u9645\u4e0a\u6bcf\u6b21\u8fd4\u56de\u7684\u90fd\u662f\u540c\u4e00\u4e2a\u5bf9\u8c61\u7684\u5f15\u7528\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>Set&lt;K&gt;<span style=\"color: rgb(97, 174, 238);\">keySet<\/span>(){Set&lt;K&gt;ks=keySet;<span style=\"color: rgb(198, 120, 221);\">if<\/span>(ks==<span style=\"color: rgb(86, 182, 194);\">null<\/span>){ks=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">KeySet<\/span>();keySet=ks;}<span style=\"color: rgb(198, 120, 221);\">return<\/span>ks;}<\/code><\/pre>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u5bf9\u8c61\u6c60<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5bf9\u8c61\u6c60\u53ef\u4ee5\u6709\u6548\u51cf\u5c11\u9891\u7e41\u7684\u5bf9\u8c61\u521b\u5efa\u548c\u9500\u6bc1\u7684\u8fc7\u7a0b\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\u5982\u679c\u6bcf\u6b21\u521b\u5efa\u5bf9\u8c61\u7684\u8fc7\u7a0b\u8f83\u4e3a\u590d\u6742\uff0c\u4e14\u5bf9\u8c61\u5360\u7528\u7a7a\u95f4\u53c8\u6bd4\u8f83\u5927\uff0c\u90a3\u4e48\u5c31\u5efa\u8bae\u4f7f\u7528\u5bf9\u8c61\u6c60\u7684\u65b9\u5f0f\u6765\u4f18\u5316\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u4f7f\u7528\u793a\u4f8b<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">org.apache.commons<\/code>\u63d0\u4f9b\u4e86\u5bf9\u8c61\u6c60\u7684\u5de5\u5177\u7c7b\uff0c\u53ef\u4ee5\u76f4\u63a5\u62ff\u6765\u4f7f\u7528<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">&lt;<span style=\"color: rgb(224, 108, 117);\">dependency<\/span>&gt;&lt;<span style=\"color: rgb(224, 108, 117);\">groupId<\/span>&gt;org.apache.commons&lt;\/<span style=\"color: rgb(224, 108, 117);\">groupId<\/span>&gt;&lt;<span style=\"color: rgb(224, 108, 117);\">artifactId<\/span>&gt;commons-pool2&lt;\/<span style=\"color: rgb(224, 108, 117);\">artifactId<\/span>&gt;&lt;<span style=\"color: rgb(224, 108, 117);\">version<\/span>&gt;2.11.1&lt;\/<span style=\"color: rgb(224, 108, 117);\">version<\/span>&gt;&lt;\/<span style=\"color: rgb(224, 108, 117);\">dependency<\/span>&gt;<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6c60\u5316\u7684\u5bf9\u8c61<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(97, 174, 238);\">@Data<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">Cache<\/span>{<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(209, 154, 102);\">byte<\/span>[]size;}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6c60\u5316\u5bf9\u8c61\u5de5\u5382<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">CachePoolObjectFactory<\/span><span style=\"color: rgb(198, 120, 221);\">extends<\/span><span style=\"color: rgb(230, 192, 123);\">BasePooledObjectFactory<\/span>&lt;Cache&gt;{<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span>Cache<span style=\"color: rgb(97, 174, 238);\">create<\/span>(){<span style=\"color: rgb(209, 154, 102);\">Cache<\/span><span style=\"color: rgb(209, 154, 102);\">cache<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Cache<\/span>();cache.setSize(<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">byte<\/span>[<span style=\"color: rgb(209, 154, 102);\">1024<\/span>*<span style=\"color: rgb(209, 154, 102);\">1024<\/span>*<span style=\"color: rgb(209, 154, 102);\">16<\/span>]);<span style=\"color: rgb(198, 120, 221);\">return<\/span>cache;}<span style=\"color: rgb(97, 174, 238);\">@Override<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span>PooledObject&lt;Cache&gt;<span style=\"color: rgb(97, 174, 238);\">wrap<\/span>(Cachecache){<span style=\"color: rgb(198, 120, 221);\">return<\/span><span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">DefaultPooledObject<\/span>&lt;&gt;(cache);}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5bf9\u8c61\u6c60\u5de5\u5177<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">import<\/span>org.apache.commons.pool2.impl.GenericObjectPool;<span style=\"color: rgb(198, 120, 221);\">import<\/span>org.apache.commons.pool2.impl.GenericObjectPoolConfig;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.time.Duration;<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">enum<\/span><span style=\"color: rgb(230, 192, 123);\">CachePoolUtil<\/span>{INSTANCE;<span style=\"color: rgb(198, 120, 221);\">private<\/span>GenericObjectPool&lt;Cache&gt;objectPool;CachePoolUtil(){GenericObjectPoolConfig&lt;Cache&gt;poolConfig=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">GenericObjectPoolConfig<\/span>&lt;&gt;();<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u5bf9\u8c61\u6c60\u4e2d\u6700\u5927\u5bf9\u8c61\u6570<\/span>poolConfig.setMaxTotal(<span style=\"color: rgb(209, 154, 102);\">50<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u5bf9\u8c61\u6c60\u4e2d\u6700\u5c0f\u7a7a\u95f2\u5bf9\u8c61\u6570<\/span>poolConfig.setMinIdle(<span style=\"color: rgb(209, 154, 102);\">20<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u5bf9\u8c61\u6c60\u4e2d\u6700\u5927\u7a7a\u95f2\u5bf9\u8c61\u6570<\/span>poolConfig.setMaxIdle(<span style=\"color: rgb(209, 154, 102);\">20<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u83b7\u53d6\u5bf9\u8c61\u6700\u5927\u7b49\u5f85\u65f6\u95f4\u9ed8\u8ba4-1\u4e00\u76f4\u7b49\u5f85<\/span>poolConfig.setMaxWait(Duration.ofSeconds(<span style=\"color: rgb(209, 154, 102);\">3<\/span>));<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u521b\u5efa\u5bf9\u8c61\u5de5\u5382<\/span><span style=\"color: rgb(209, 154, 102);\">CachePoolObjectFactory<\/span><span style=\"color: rgb(209, 154, 102);\">objectFactory<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">CachePoolObjectFactory<\/span>();<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u521b\u5efa\u5bf9\u8c61\u6c60<\/span>objectPool=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">GenericObjectPool<\/span>&lt;&gt;(objectFactory,poolConfig);}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u4ece\u5bf9\u8c61\u6c60\u4e2d\u53d6\u51fa\u4e00\u4e2a\u5bf9\u8c61*\/<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span>Cache<span style=\"color: rgb(97, 174, 238);\">borrowObject<\/span>()<span style=\"color: rgb(198, 120, 221);\">throws<\/span>Exception{<span style=\"color: rgb(198, 120, 221);\">return<\/span>objectPool.borrowObject();}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">returnObject<\/span>(Cachecache){<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u5c06\u5bf9\u8c61\u5f52\u8fd8\u7ed9\u5bf9\u8c61\u6c60<\/span>objectPool.returnObject(cache);}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u83b7\u53d6\u6d3b\u8dc3\u7684\u5bf9\u8c61\u6570*\/<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(97, 174, 238);\">getNumActive<\/span>(){<span style=\"color: rgb(198, 120, 221);\">return<\/span>objectPool.getNumActive();}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/***\u83b7\u53d6\u7a7a\u95f2\u7684\u5bf9\u8c61\u6570*\/<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(97, 174, 238);\">getNumIdle<\/span>(){<span style=\"color: rgb(198, 120, 221);\">return<\/span>objectPool.getNumIdle();}}<\/code><\/pre>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">Main<\/span>{<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args){<span style=\"color: rgb(209, 154, 102);\">CachePoolUtil<\/span><span style=\"color: rgb(209, 154, 102);\">cachePoolUtil<\/span>=CachePoolUtil.INSTANCE;<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">10<\/span>;i++){<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Runnable<\/span>(){<span style=\"color: rgb(97, 174, 238);\">@SneakyThrows<\/span><span style=\"color: rgb(97, 174, 238);\">@Override<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">run<\/span>(){<span style=\"color: rgb(198, 120, 221);\">while<\/span>(<span style=\"color: rgb(86, 182, 194);\">true<\/span>){Thread.sleep(<span style=\"color: rgb(209, 154, 102);\">100<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u4f7f\u7528\u5bf9\u8c61\u6c60<\/span><span style=\"color: rgb(209, 154, 102);\">Cache<\/span><span style=\"color: rgb(209, 154, 102);\">cache<\/span>=cachePoolUtil.borrowObject();m(cache);cachePoolUtil.returnObject(cache);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u4e0d\u4f7f\u7528\u5bf9\u8c61\u6c60<\/span><span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/Cachecache=newCache();<\/span><span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/cache.setSize(newbyte[1024*1024*2]);<\/span><span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/m(cache);<\/span>}}}).start();}}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u65e0\u7279\u6b8a\u4f5c\u7528<\/span><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">m<\/span>(Cachecache){<span style=\"color: rgb(198, 120, 221);\">if<\/span>(cache.getSize().length&lt;<span style=\"color: rgb(209, 154, 102);\">10<\/span>){System.out.println(cache);}}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f7f\u7528\u5bf9\u8c61\u6c60<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100037002\" data-ratio=\"0.3398148148148148\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100037002\" data-ratio=\"0.3398148148148148\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><\/noscript><\/figure>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e0d\u9002\u7528\u5bf9\u8c61\u6c60<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100037001\" data-ratio=\"0.3212962962962963\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100037001\" data-ratio=\"0.3212962962962963\" data-type=\"other\" data-w=\"1080\"  src=\"\"  \/><\/noscript><\/figure>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">8. \u5e76\u53d1\u5904\u7406<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u9501\u7684\u7c92\u5ea6\u63a7\u5236<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5e76\u53d1\u573a\u666f\u4e0b\u5c31\u8981\u8003\u8651\u7ebf\u7a0b\u5b89\u5168\u7684\u95ee\u9898\uff0c\u5e38\u89c1\u7684\u89e3\u51b3\u65b9\u5f0f\uff1avolatile\u3001CAS\u3001\u81ea\u65cb\u9501\u3001\u5bf9\u8c61\u9501\u3001\u7c7b\u9501\u3001\u5206\u6bb5\u9501\u3001\u8bfb\u5199\u9501\uff0c\u7406\u8bba\u4e0a\u6765\u8bf4\uff0c\u9501\u7684\u7c92\u5ea6\u8d8a\u5c0f\uff0c\u5e76\u884c\u6548\u679c\u5c31\u8d8a\u9ad8\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">volatile<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">volatile\u662fJava\u4e2d\u7684\u4e00\u4e2a\u5173\u952e\u5b57\uff0c\u7528\u4e8e\u4fee\u9970\u53d8\u91cf\u3002\u5b83\u7684\u4f5c\u7528\u662f\u4fdd\u8bc1\u88abvolatile\u4fee\u9970\u7684\u53d8\u91cf\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u7684\u53ef\u89c1\u6027\u548c\u7981\u6b62\u6307\u4ee4\u91cd\u6392\u5e8f\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">volatile\u867d\u7136\u4e0d\u80fd\u4fdd\u8bc1\u539f\u5b50\u6027\uff0c\u4f46\u5982\u679c\u5bf9\u5171\u4eab\u53d8\u91cf\u662f\u7eaf\u8d4b\u503c\u6216\u8bfb\u53d6\u7684\u64cd\u4f5c\uff0c\u90a3\u4e48\u56e0\u4e3avolatile\u4fdd\u8bc1\u4e86\u53ef\u89c1\u6027\uff0c\u56e0\u6b64\u4e5f\u662f\u53ef\u4ee5\u5b9e\u73b0\u7ebf\u7a0b\u5b89\u5168\u7684\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">CAS<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">compare and swap\uff08\u6bd4\u8f83\u5e76\u4ea4\u6362\uff09\uff0cCAS\u4e3b\u8981\u6709\u4e09\u4e2a\u53c2\u6570\uff0c<\/p>\n<ul style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022 V\uff1a\u5185\u5b58\u503c<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022 A\uff1a\u5f53\u524d\u65f6<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022 B\uff1a\u5f85\u66f4\u65b0\u7684\u503c<\/p>\n<\/li>\n<\/ul>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5f53\u4e14\u4ec5\u5f53V\u7b49\u4e8eA\u65f6\uff0c\u5c31\u5c06A\u66f4\u65b0\u4e3aB\uff0c\u5426\u5219\u4ec0\u4e48\u90fd\u4e0d\u505a\u3002V\u548cA\u7684\u6bd4\u8f83\u662f\u4e00\u4e2a\u539f\u5b50\u6027\u64cd\u4f5c\u4fdd\u8bc1\u7ebf\u7a0b\u5b89\u5168\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">Random\u901a\u8fc7cas\u7684\u65b9\u5f0f\u4fdd\u8bc1\u4e86\u7ebf\u7a0b\u5b89\u5168\uff0c\u4f46\u5728\u9ad8\u5e76\u53d1\u4e0b\u5f88\u6709\u53ef\u80fd\u4f1a\u5931\u8d25\uff0c\u9020\u6210\u9891\u7e41\u7684\u91cd\u8bd5\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">protected<\/span><span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(97, 174, 238);\">next<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span>bits){<span style=\"color: rgb(209, 154, 102);\">long<\/span>oldseed,nextseed;<span style=\"color: rgb(209, 154, 102);\">AtomicLong<\/span><span style=\"color: rgb(209, 154, 102);\">seed<\/span>=<span style=\"color: rgb(230, 192, 123);\">this<\/span>.seed;<span style=\"color: rgb(198, 120, 221);\">do<\/span>{oldseed=seed.get();nextseed=(oldseed*multiplier+addend)&amp;mask;}<span style=\"color: rgb(198, 120, 221);\">while<\/span>(!seed.compareAndSet(oldseed,nextseed));<span style=\"color: rgb(198, 120, 221);\">return<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span>)(nextseed&gt;&gt;&gt;(<span style=\"color: rgb(209, 154, 102);\">48<\/span>-bits));}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">ThreadLocalRandom\u8fdb\u884c\u4e86\u4f18\u5316\uff0c\u5176\u4e3b\u8981\u65b9\u5f0f\u5c31\u662f\u5206\u6bb5\uff0c\u901a\u8fc7\u8ba9\u6bcf\u4e2a\u7ebf\u7a0b\u62e5\u6709\u72ec\u7acb\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u8fd9\u6837\u5373\u4fdd\u8bc1\u4e86\u7ebf\u7a0b\u5b89\u5168\uff0c\u540c\u65f6\u6548\u7387\u4e5f\u4e0d\u4f1a\u592a\u5dee\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span>ThreadLocalRandom<span style=\"color: rgb(97, 174, 238);\">current<\/span>(){<span style=\"color: rgb(198, 120, 221);\">if<\/span>(U.getInt(Thread.currentThread(),PROBE)==<span style=\"color: rgb(209, 154, 102);\">0<\/span>)localInit();<span style=\"color: rgb(198, 120, 221);\">return<\/span>instance;}<span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">localInit<\/span>(){<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">p<\/span>=probeGenerator.addAndGet(PROBE_INCREMENT);<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">probe<\/span>=(p==<span style=\"color: rgb(209, 154, 102);\">0<\/span>)?<span style=\"color: rgb(209, 154, 102);\">1<\/span>:p;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/skip0<\/span><span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">seed<\/span>=mix64(seeder.getAndAdd(SEEDER_INCREMENT));<span style=\"color: rgb(209, 154, 102);\">Thread<\/span><span style=\"color: rgb(209, 154, 102);\">t<\/span>=Thread.currentThread();U.putLong(t,SEED,seed);U.putInt(t,PROBE,probe);}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(97, 174, 238);\">nextInt<\/span>(){<span style=\"color: rgb(198, 120, 221);\">return<\/span>mix32(nextSeed());}<span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(97, 174, 238);\">nextSeed<\/span>(){Threadt;<span style=\"color: rgb(209, 154, 102);\">long<\/span>r;<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/readandupdateper-threadseed<\/span>U.putLong(t=Thread.currentThread(),SEED,r=U.getLong(t,SEED)+GAMMA);<span style=\"color: rgb(198, 120, 221);\">return<\/span>r;}<\/code><\/pre>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u5bf9\u8c61\u9501\u3001\u7c7b\u9501<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4e3b\u8981\u5c31\u662f\u901a\u8fc7synchronized\u5b9e\u73b0\uff0c\u662f\u6700\u57fa\u7840\u7684\u9501\u673a\u5236\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u81ea\u65cb\u9501<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u81ea\u65cb\u9501\u4e2d\uff0c\u5f53\u4e00\u4e2a\u64cd\u4f5c\u9700\u8981\u8bbf\u95ee\u4e00\u4e2a\u5171\u4eab\u8d44\u6e90\u65f6\uff0c\u5b83\u4f1a\u68c0\u67e5\u8fd9\u4e2a\u8d44\u6e90\u662f\u5426\u88ab\u5176\u4ed6\u64cd\u4f5c\u5360\u7528\u3002\u5982\u679c\u662f\uff0c\u5b83\u4f1a\u4e00\u76f4\u7b49\u5f85\uff0c\u76f4\u5230\u8d44\u6e90\u88ab\u91ca\u653e\u3002\u5728\u7b49\u5f85\u671f\u95f4\uff0c\u8fd9\u4e2a\u64cd\u4f5c\u4f1a\u8fdb\u5165\u4e00\u4e2a\u81ea\u65cb\u72b6\u6001\uff0c\u4e5f\u5c31\u662f\u4e0d\u4f1a\u88ab\u7cfb\u7edf\u6302\u8d77\uff0c\u4f46\u662f\u4e5f\u4e0d\u4f1a\u7ee7\u7eed\u6267\u884c\u5176\u4ed6\u4efb\u52a1\u3002\u5f53\u8d44\u6e90\u88ab\u91ca\u653e\u540e\uff0c\u8fd9\u4e2a\u64cd\u4f5c\u4f1a\u7acb\u5373\u8fd4\u56de\u5e76\u7ee7\u7eed\u6267\u884c\u4e0b\u4e00\u6b65\u64cd\u4f5c\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u81ea\u65cb\u9501\u662f\u4e00\u79cd\u7b80\u5355\u800c\u6709\u6548\u7684\u540c\u6b65\u673a\u5236\uff0c\u81ea\u65cb\u9501\u7684\u4f18\u70b9\u662f\u51cf\u5c11\u7ebf\u7a0b\u4e0a\u4e0b\u6587\u5207\u6362\u7684\u5f00\u9500\uff0c\u4f46\u662f\u5b83\u4e5f\u6709\u4e00\u4e9b\u7f3a\u70b9\u3002\u7531\u4e8e\u5b83\u9700\u8981\u4e00\u76f4\u8fdb\u884c\u81ea\u65cb\u64cd\u4f5c\uff0c\u6240\u4ee5\u4f1a\u6d88\u8017\u4e00\u5b9a\u7684CPU\u8d44\u6e90\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528\u81ea\u65cb\u9501\u65f6\u9700\u8981\u4ed4\u7ec6\u8003\u8651\u5e76\u53d1\u95ee\u9898\u548c\u6027\u80fd\u95ee\u9898\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u5206\u6bb5\u9501<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5728\u5206\u6bb5\u9501\u7684\u6a21\u578b\u4e2d\uff0c\u5171\u4eab\u6570\u636e\u88ab\u5206\u5272\u6210\u82e5\u5e72\u4e2a\u6bb5\uff0c\u6bcf\u4e2a\u6bb5\u90fd\u88ab\u4e00\u4e2a\u9501\u6240\u4fdd\u62a4\uff0c\u540c\u65f6\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u53ef\u4ee5\u5728\u540c\u4e00\u65f6\u523b\u5bf9\u540c\u4e00\u6bb5\u8fdb\u884c\u52a0\u9501\u548c\u89e3\u9501\u64cd\u4f5c\u3002\u8fd9\u79cd\u9501\u673a\u5236\u53ef\u4ee5\u964d\u4f4e\u9501\u7684\u7ade\u4e89\uff0c\u63d0\u9ad8\u5e76\u53d1\u8bbf\u95ee\u7684\u6548\u7387\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">ConcurrentHashMap\u7684\u8bbe\u8ba1\u5c31\u662f\u91c7\u7528\u5206\u6bb5\u9501\u7684\u601d\u60f3\uff0c\u5176\u4f1a\u6309\u7167map\u4e2d\u7684table capacity\uff08\u9ed8\u8ba416\uff09\u6765\u5212\u5206\uff0c\u4e5f\u5c31\u662f\u8bf4\u6bcf\u4e2a\u7ebf\u7a0b\u4f1a\u95011\/16\u7684\u6570\u636e\u6bb5\uff0c\u8fd9\u6837\u4e00\u6765\u5c31\u5927\u5927\u63d0\u5347\u4e86\u5e76\u53d1\u8bbf\u95ee\u7684\u6548\u7387\u3002<\/p>\n<h4 style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin: 2em 8px 0.5em;color: rgb(250, 81, 81);\">\u8bfb\u5199\u9501<\/h4>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u8bfb\u5199\u9501\u4e3b\u8981\u6839\u636e\u5927\u591a\u6570\u4e1a\u52a1\u573a\u666f\u90fd\u662f\u8bfb\u591a\u5199\u5c11\u7684\u60c5\u51b5\uff0c\u5728\u8bfb\u6570\u636e\u65f6\uff0c\u65e0\u8bba\u591a\u5c11\u7ebf\u7a0b\u540c\u65f6\u8bbf\u95ee\u90fd\u4e0d\u4f1a\u6709\u5b89\u5168\u95ee\u9898\uff0c\u6240\u4ee5\u5728\u8bfb\u6570\u636e\u7684\u65f6\u5019\u53ef\u4ee5\u4e0d\u52a0\u9501\uff0c\u4e0d\u8fc7\u4e00\u65e6\u6709\u5199\u8bf7\u6c42\u65f6\u5c31\u9700\u8981\u52a0\u9501\u4e86\u3002<\/p>\n<ul style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;padding-left: 1em;list-style: circle;color: rgb(63, 63, 63);\" class=\"list-paddingleft-1\">\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022\u8bfb\u3001\u8bfb\uff1a\u4e0d\u51b2\u7a81<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022\u8bfb\u3001\u5199\uff1a\u51b2\u7a81<\/p>\n<\/li>\n<li style=\"text-align: left;line-height: 1.75;text-indent: -1em;display: block;margin: 0.2em 8px;\">\n<p>\u2022\u5199\u3001\u5199\uff1a\u51b2\u7a81<\/p>\n<\/li>\n<\/ul>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5178\u578b\u7684\u5982\uff1a<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ReentrantReadWriteLock<\/code><\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100037000\" data-ratio=\"0.2972222222222222\" data-type=\"other\" data-w=\"1080\"  style=\"line-height: 1.75;border-radius: 4px;display: block;margin: 0.1em auto 0.5em;height: auto !important;\" title=\"null\" src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100037000\" data-ratio=\"0.2972222222222222\" data-type=\"other\" data-w=\"1080\"  style=\"line-height: 1.75;border-radius: 4px;display: block;margin: 0.1em auto 0.5em;height: auto !important;\" title=\"null\" src=\"\"  \/><\/noscript><\/figure>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u5199\u65f6\u590d\u5236<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5199\u65f6\u590d\u5236\u6700\u5927\u7684\u4f18\u52bf\u5728\u4e8e\uff0c\u5728\u5199\u6570\u636e\u7684\u8fc7\u7a0b\u65f6\uff0c\u4e0d\u5f71\u54cd\u8bfb\uff0c\u53ef\u4ee5\u7406\u89e3\u4e3a\u8bfb\u7684\u662f\u6570\u636e\u7684\u526f\u672c\uff0c\u800c\u53ea\u6709\u5f53\u6570\u636e\u771f\u6b63\u5199\u5b8c\u540e\u624d\u4f1a\u66ff\u6362\u526f\u672c\uff0c\u5f53\u526f\u672c\u7279\u522b\u5927\u3001\u5199\u6570\u636e\u8fc7\u7a0b\u6bd4\u8f83\u6f2b\u957f\u65f6\uff0c\u5199\u65f6\u590d\u5236\u5c31\u7279\u522b\u6709\u7528\u4e86\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\"><code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CopyOnWriteArrayList<\/code>\u3001<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CopyOnWriteArraySet<\/code>\u5c31\u662f\u96c6\u5408\u64cd\u4f5c\u65f6\uff0c\u4e3a\u4fdd\u8bc1\u7ebf\u7a0b\u5b89\u5168\uff0c\u4f7f\u7528\u5199\u65f6\u590d\u5236\u7684\u5b9e\u73b0<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span>E<span style=\"color: rgb(97, 174, 238);\">get<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span>index){<span style=\"color: rgb(198, 120, 221);\">return<\/span>elementAt(getArray(),index);}<span style=\"color: rgb(198, 120, 221);\">final<\/span>Object[]getArray(){<span style=\"color: rgb(198, 120, 221);\">return<\/span>array;}<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(209, 154, 102);\">boolean<\/span><span style=\"color: rgb(97, 174, 238);\">add<\/span>(Ee){<span style=\"color: rgb(198, 120, 221);\">synchronized<\/span>(lock){Object[]es=getArray();<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">len<\/span>=es.length;es=Arrays.copyOf(es,len+<span style=\"color: rgb(209, 154, 102);\">1<\/span>);es[len]=e;setArray(es);<span style=\"color: rgb(198, 120, 221);\">return<\/span><span style=\"color: rgb(86, 182, 194);\">true<\/span>;}}<span style=\"color: rgb(198, 120, 221);\">final<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">setArray<\/span>(Object[]a){array=a;}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5199\u65f6\u590d\u5236\u4e5f\u5b58\u5728\u4e24\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u770b\u5230\u5728add\u65b9\u6cd5\u65f6\u4f7f\u7528\u4e86synchronized\uff0c\u4e5f\u5c31\u662f\u8bf4\u5f53\u5b58\u5728\u5927\u91cf\u7684\u5199\u5165\u64cd\u4f5c\u65f6\uff0c\u6548\u7387\u5b9e\u9645\u4e0a\u662f\u975e\u5e38\u4f4e\u7684\uff0c\u53e6\u4e00\u4e2a\u95ee\u9898\u5c31\u662f\u9700\u8981copy\u4e00\u4efd\u4e00\u6a21\u4e00\u6837\u7684\u6570\u636e\uff0c\u53ef\u80fd\u4f1a\u9020\u6210\u5185\u5b58\u7684\u5f02\u5e38\u6ce2\u52a8\uff0c\u56e0\u6b64\u5199\u65f6\u590d\u5236\u5b9e\u9645\u4e0a\u9002\u7528\u4e8e\u8bfb\u591a\u5199\u5c11\u7684\u573a\u666f\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5bf9\u6bd4\u8bf4\u660e<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.Collections;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.Iterator;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.Set;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.UUID;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.ConcurrentHashMap;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.CopyOnWriteArraySet;<span style=\"color: rgb(198, 120, 221);\">import<\/span>java.util.concurrent.CountDownLatch;<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">ThreadSafeSet<\/span>{<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>InterruptedException{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/Set&lt;String&gt;set=ConcurrentHashMap.newKeySet();<\/span><span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/CopyOnWriteArraySet&lt;String&gt;set=newCopyOnWriteArraySet();<\/span>readMoreWriteLess(set);System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"==========\u534e\u4e3d\u7684\u5206\u9694\u7b26==========\"<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/set=ConcurrentHashMap.newKeySet();<\/span><span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/set=newCopyOnWriteArraySet();<\/span>writeMoreReadLess(set);}<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">writeMoreReadLess<\/span>(Set&lt;String&gt;set)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>InterruptedException{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u6d4b20\u7ec4<\/span><span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">k<\/span>=<span style=\"color: rgb(209, 154, 102);\">1<\/span>;k&lt;=<span style=\"color: rgb(209, 154, 102);\">20<\/span>;k++){<span style=\"color: rgb(209, 154, 102);\">CountDownLatch<\/span><span style=\"color: rgb(209, 154, 102);\">countDownLatch<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">CountDownLatch<\/span>(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">s<\/span>=System.currentTimeMillis();<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u521b\u5efa9\u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u5411set\u4e2d\u51991000\u6761\u6570\u636e<\/span><span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">9<\/span>;i++){<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">j<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;j&lt;<span style=\"color: rgb(209, 154, 102);\">1000<\/span>;j++){set.add(UUID.randomUUID().toString());}countDownLatch.countDown();}).start();}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u521b\u5efa1\u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u4eceset\u4e2d\u8bfb\u53d6\u6240\u6709\u6570\u636e\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u4e00\u5171\u8bfb\u53d610\u6b21\u3002<\/span><span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">1<\/span>;i++){<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">j<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;j&lt;<span style=\"color: rgb(209, 154, 102);\">10<\/span>;j++){Iterator&lt;String&gt;iterator=set.iterator();<span style=\"color: rgb(198, 120, 221);\">while<\/span>(iterator.hasNext()){iterator.next();}}countDownLatch.countDown();}).start();}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u963b\u585e\uff0c\u76f4\u523010\u4e2a\u7ebf\u7a0b\u90fd\u6267\u884c\u7ed3\u675f<\/span>countDownLatch.await();<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e<\/span>=System.currentTimeMillis();System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u5199\u591a\u8bfb\u5c11\uff1a\u7b2c\"<\/span>+k+<span style=\"color: rgb(152, 195, 121);\">\"\u6b21\u6267\u884c\u8017\u65f6\uff1a\"<\/span>+(e-s)+<span style=\"color: rgb(152, 195, 121);\">\"\u6beb\u79d2\"<\/span>+<span style=\"color: rgb(152, 195, 121);\">\"\uff0c\u5bb9\u5668\u4e2d\u5143\u7d20\u4e2a\u6570\u4e3a\uff1a\"<\/span>+set.size());}}<span style=\"color: rgb(198, 120, 221);\">private<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">readMoreWriteLess<\/span>(Set&lt;String&gt;set)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>InterruptedException{<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u6d4b20\u7ec4<\/span><span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">k<\/span>=<span style=\"color: rgb(209, 154, 102);\">1<\/span>;k&lt;=<span style=\"color: rgb(209, 154, 102);\">20<\/span>;k++){<span style=\"color: rgb(209, 154, 102);\">CountDownLatch<\/span><span style=\"color: rgb(209, 154, 102);\">countDownLatch<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">CountDownLatch<\/span>(<span style=\"color: rgb(209, 154, 102);\">10<\/span>);<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">s<\/span>=System.currentTimeMillis();<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u521b\u5efa1\u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u5411set\u4e2d\u519910\u6761\u6570\u636e<\/span><span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">1<\/span>;i++){<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">j<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;j&lt;<span style=\"color: rgb(209, 154, 102);\">10<\/span>;j++){set.add(UUID.randomUUID().toString());}countDownLatch.countDown();}).start();}<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u521b\u5efa9\u4e2a\u7ebf\u7a0b\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u4eceset\u4e2d\u8bfb\u53d6\u6240\u6709\u6570\u636e\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u4e00\u5171\u8bfb\u53d6100\u4e07\u6b21\u3002<\/span><span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">9<\/span>;i++){<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">j<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;j&lt;<span style=\"color: rgb(209, 154, 102);\">1000000<\/span>;j++){Iterator&lt;String&gt;iterator=set.iterator();<span style=\"color: rgb(198, 120, 221);\">while<\/span>(iterator.hasNext()){iterator.next();}}countDownLatch.countDown();}).start();}countDownLatch.await();<span style=\"color: rgb(209, 154, 102);\">long<\/span><span style=\"color: rgb(209, 154, 102);\">e<\/span>=System.currentTimeMillis();System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u8bfb\u591a\u5199\u5c11\uff1a\u7b2c\"<\/span>+k+<span style=\"color: rgb(152, 195, 121);\">\"\u6b21\u6267\u884c\u8017\u65f6\uff1a\"<\/span>+(e-s)+<span style=\"color: rgb(152, 195, 121);\">\"\u6beb\u79d2\"<\/span>+<span style=\"color: rgb(152, 195, 121);\">\"\uff0c\u5bb9\u5668\u4e2d\u5143\u7d20\u4e2a\u6570\u4e3a\uff1a\"<\/span>+set.size());}}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u7ecf\u8fc7\u6d4b\u8bd5\u53ef\u4ee5\u53d1\u73b0\u5728\u8bfb\u591a\u5199\u5c11\u65f6<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CopyOnWriteArraySet<\/code>\u4f1a\u660e\u663e\u4f18\u4e8e<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ConcurrentHashMap.newKeySet()<\/code>\uff0c\u4f46\u5728\u5199\u591a\u8bfb\u5c11\u65f6\u53c8\u4f1a\u660e\u663e\u5f31\u4e8e<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">ConcurrentHashMap.newKeySet()<\/code>\u3002<\/p>\n<blockquote style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;border-left: none;padding: 1em;border-radius: 8px;color: rgba(0, 0, 0, 0.5);background: rgb(247, 247, 247);margin: 2em 8px;\">\n<p style=\"line-height: 1.75;font-size: 1em;letter-spacing: 0.1em;color: rgb(80, 80, 80);\">\u5f53\u7136\u4f7f\u7528<code style=\"line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CopyOnWriteArraySet<\/code>\u8fd8\u9700\u8981\u6ce8\u610f\u4e00\u70b9\uff0c\u5199\u5165\u7684\u6570\u636e\u53ef\u80fd\u4e0d\u4f1a\u88ab\u53ca\u65f6\u7684\u8bfb\u53d6\u5230\uff0c\u56e0\u4e3a\u904d\u5386\u7684\u662f\u8bfb\u53d6\u4e4b\u524d\u83b7\u53d6\u7684\u5feb\u7167\u3002<\/p>\n<\/blockquote>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u8fd9\u6bb5\u4ee3\u7801\u53ef\u4ee5\u6d4b\u8bd5<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">CopyOnWriteArraySet<\/code>\u5199\u5165\u6570\u636e\u4e0d\u80fd\u88ab\u53ca\u65f6\u8bfb\u53d6\u5230\u7684\u95ee\u9898\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">class<\/span><span style=\"color: rgb(230, 192, 123);\">COWSetTest<\/span>{<span style=\"color: rgb(198, 120, 221);\">public<\/span><span style=\"color: rgb(198, 120, 221);\">static<\/span><span style=\"color: rgb(198, 120, 221);\">void<\/span><span style=\"color: rgb(97, 174, 238);\">main<\/span>(String[]args)<span style=\"color: rgb(198, 120, 221);\">throws<\/span>InterruptedException{CopyOnWriteArraySet&lt;Integer&gt;set=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">CopyOnWriteArraySet<\/span>();<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">try<\/span>{set.add(<span style=\"color: rgb(209, 154, 102);\">1<\/span>);System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u7b2c\u4e00\u4e2a\u7ebf\u7a0b\u542f\u52a8\uff0c\u6dfb\u52a0\u4e86\u4e00\u4e2a\u5143\u7d20\uff0c\u7761100\u6beb\u79d2\"<\/span>);Thread.sleep(<span style=\"color: rgb(209, 154, 102);\">100<\/span>);set.add(<span style=\"color: rgb(209, 154, 102);\">2<\/span>);set.add(<span style=\"color: rgb(209, 154, 102);\">3<\/span>);System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u7b2c\u4e00\u4e2a\u7ebf\u7a0b\u6dfb\u52a0\u4e863\u4e2a\u5143\u7d20\uff0c\u6267\u884c\u7ed3\u675f\"<\/span>);}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}}).start();<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u4fdd\u8bc1\u8ba9\u7b2c\u4e00\u4e2a\u7ebf\u7a0b\u5148\u6267\u884c<\/span>Thread.sleep(<span style=\"color: rgb(209, 154, 102);\">1<\/span>);<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">Thread<\/span>(()-&gt;{<span style=\"color: rgb(198, 120, 221);\">try<\/span>{System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b\u542f\u52a8\u4e86\uff01\u7761200\u6beb\u79d2\"<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/Thread.sleep(200);\/\/\u5982\u679c\u5728\u8fd9\u8fb9\u7761\u7720\uff0c\u53ef\u4ee5\u83b7\u53d6\u52303\u4e2a\u5143\u7d20<\/span>Iterator&lt;Integer&gt;iterator=set.iterator();<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u751f\u6210\u5feb\u7167<\/span>Thread.sleep(<span style=\"color: rgb(209, 154, 102);\">200<\/span>);<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/\u5982\u679c\u5728\u8fd9\u8fb9\u7761\u7720\uff0c\u53ea\u80fd\u83b7\u53d6\u52301\u4e2a\u5143\u7d20<\/span><span style=\"color: rgb(198, 120, 221);\">while<\/span>(iterator.hasNext()){System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u7b2c\u4e8c\u4e2a\u7ebf\u7a0b\u5f00\u59cb\u904d\u5386\uff0c\u83b7\u53d6\u5230\u5143\u7d20\uff1a\"<\/span>+iterator.next());}}<span style=\"color: rgb(198, 120, 221);\">catch<\/span>(InterruptedExceptione){e.printStackTrace();}}).start();}}<\/code><\/pre>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">9. \u5f02\u6b65<\/h1>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5f02\u6b65\u662f\u63d0\u5347\u7cfb\u7edf\u54cd\u5e94\u80fd\u529b\u7684\u91cd\u8981\u624b\u6bb5\u4e4b\u4e00\uff0c\u5f02\u6b65\u601d\u60f3\u7684\u5e94\u7528\u4e5f\u975e\u5e38\u7684\u5e7f\u6cdb\uff0c\u5e38\u89c1\u7684\u6709\uff1a\u7ebf\u7a0b\u3001MQ\u3001\u4e8b\u4ef6\u901a\u77e5\u3001\u54cd\u5e94\u5f0f\u7f16\u7a0b\u7b49\u65b9\u5f0f\uff0c\u6709\u4e9b\u6982\u5ff5\u5728\u524d\u9762\u7684\u7ae0\u8282\u4e2d\u4e5f\u6d89\u53ca\u5230\u4e86\uff0c\u5f02\u6b65\u6700\u6838\u5fc3\u7684\u601d\u60f3\u5c31\u662f\uff0c\u5148\u5feb\u901f\u63a5\u6536\uff0c\u540e\u67e5\u8be2\u7ed3\u679c\uff0c\u6bd4\u5982\uff1a\u5982\u679c\u63a5\u53e3\u5904\u7406\u65f6\u95f4\u8f83\u957f\uff0c\u90a3\u4e48\u53ef\u4ee5\u4f18\u5148\u54cd\u5e94\u4e2d\u95f4\u72b6\u6001\uff08\u5904\u7406\u4e2d\uff09\uff0c\u7136\u540e\u63d0\u4f9b\u56de\u8c03\u548c\u67e5\u8be2\u63a5\u53e3\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u5927\u5927\u63d0\u5347\u63a5\u53e3\u7684\u541e\u5410\u91cf\uff01<\/p>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">10. for\u5faa\u73af\u4f18\u5316<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u51cf\u5c11\u5faa\u73af<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u4e00\u4e9b\u9ad8\u6548\u7684\u7b97\u6cd5\u6216\u8005\u6570\u636e\u7ed3\u6784\u6765\u51cf\u5c11\u5faa\u73af\u6b21\u6570\uff0c\u5c24\u5176\u5f53\u51fa\u73b0\u5d4c\u5957\u5faa\u73af\u65f6\u8981\u683c\u5916\u5c0f\u5fc3\u3002\u5e38\u89c1\u7684\u65b9\u5f0f\u6bd4\u5982\uff1a\u6709\u5e8f\u7684\u67e5\u627e\u53ef\u4ee5\u7528\u4e8c\u5206\uff0c\u6392\u5e8f\u53ef\u4ee5\u7528\u5feb\u6392\uff0c\u68c0\u7d22\u53ef\u4ee5\u6784\u5efaHash\u7d22\u5f15\u7b49\u7b49\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u6279\u91cf\u83b7\u53d6<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f18\u5316\u524d\uff1a\u6bcf\u6b21\u67e5\u8be2\u4e00\u6b21\u6570\u636e\u5e93<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(198, 120, 221);\">for<\/span>(StringuserId:userIds){<span style=\"color: rgb(209, 154, 102);\">User<\/span><span style=\"color: rgb(209, 154, 102);\">user<\/span>=userMapper.queryById(userId);<span style=\"color: rgb(198, 120, 221);\">if<\/span>(user.getName().equals(<span style=\"color: rgb(152, 195, 121);\">\"xxx\"<\/span>)){<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/...<\/span>}}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f18\u5316\u540e\uff1a\u5148\u6279\u91cf\u67e5\u8be2\u51fa\u6765\uff0c\u518d\u5904\u7406<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">Map&lt;String,User&gt;userMap=userMapper.queryByIds(userIds);<span style=\"color: rgb(198, 120, 221);\">for<\/span>(StringuserId:userIds){<span style=\"color: rgb(209, 154, 102);\">User<\/span><span style=\"color: rgb(209, 154, 102);\">user<\/span>=userMap.get(userId);<span style=\"color: rgb(198, 120, 221);\">if<\/span>(user.getName().equals(<span style=\"color: rgb(152, 195, 121);\">\"xxx\"<\/span>)){<span style=\"color: rgb(92, 99, 112);font-style: italic;\">\/\/...<\/span>}}<\/code><\/pre>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7f13\u5b58\u7ed3\u679c<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f18\u5316\u524d\uff1a\u6bcf\u6b21\u90fd\u8981\u6839\u636e\u6bcf\u4e2a\u7528\u6237\u7684roleId\u53bb\u6570\u636e\u5e93\u67e5\u8be2\u4e00\u6b21\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">Map&lt;String,User&gt;userMap=userMapper.queryByIds(userIds);<span style=\"color: rgb(198, 120, 221);\">for<\/span>(StringuserId:userIds){<span style=\"color: rgb(209, 154, 102);\">User<\/span><span style=\"color: rgb(209, 154, 102);\">user<\/span>=userMap.get(userId);<span style=\"color: rgb(209, 154, 102);\">Role<\/span><span style=\"color: rgb(209, 154, 102);\">role<\/span>=roleMapper.queryById(user.getRoleId());}<\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f18\u5316\u540e\uff1a\u6bcf\u6b21\u6839\u636eroleId\u67e5\u8be2\u8fc7\u4ee5\u540e\u5c31\u6682\u8bb0\u4e0b\u6765\uff0c\u540e\u9762\u518d\u9047\u5230\u76f8\u540croleId\u65f6\u5373\u53ef\u76f4\u63a5\u83b7\u53d6\uff0c\u8fd9\u6bd4\u8f83\u9002\u7528\u4e8e\u4e00\u6b21\u5faa\u73af\u4e2droleId\u91cd\u590d\u6b21\u6570\u8f83\u591a\u7684\u573a\u666f\u3002<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">Map&lt;String,User&gt;userMap=userMapper.queryByIds(userIds);Map&lt;String,Role&gt;roleMap=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">HashMap<\/span>&lt;&gt;();<span style=\"color: rgb(198, 120, 221);\">for<\/span>(StringuserId:userIds){<span style=\"color: rgb(209, 154, 102);\">User<\/span><span style=\"color: rgb(209, 154, 102);\">user<\/span>=userMap.get(userId);<span style=\"color: rgb(209, 154, 102);\">Role<\/span><span style=\"color: rgb(209, 154, 102);\">role<\/span>=roleMap.get(user.getRoleId());<span style=\"color: rgb(198, 120, 221);\">if<\/span>(role==<span style=\"color: rgb(86, 182, 194);\">null<\/span>){role=roleMapper.queryById(user.getRoleId());roleMap.put(user.getRoleId(),role);}}<\/code><\/pre>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u5e76\u884c\u5904\u7406<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5178\u578b\u7684\u5982parallelStream<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(209, 154, 102);\">Integer<\/span><span style=\"color: rgb(209, 154, 102);\">sum<\/span>=numbers.parallelStream().reduce(<span style=\"color: rgb(209, 154, 102);\">0<\/span>,Integer::sum);<\/code><\/pre>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">11. \u51cf\u5c11\u7f51\u7edc\u4f20\u8f93\u7684\u4f53\u79ef<\/h1>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7cbe\u7b80\u5b57\u6bb5<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">1.\u6570\u636e\u5e93\u67e5\u8be2\u65f6\u8981\u907f\u514d\u9891\u7e41\u67e5\u8be2\u5927\u6587\u672c\u5b57\u6bb5\uff0c\u5e38\u89c1\u7684\u5982\u4e0b\u9762\u51e0\u79cd\uff1a<code style=\"text-align: left;line-height: 1.75;font-size: 13.5px;color: rgb(221, 17, 68);background: rgba(27, 31, 35, 0.05);padding: 3px 5px;border-radius: 4px;\">select url, describe, remark from t<\/code><\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">2.\u63a5\u53e3\u4f20\u8f93\u65f6\u540c\u6837\u8981\u6ce8\u610f\u5c3d\u91cf\u51cf\u5c11\u5185\u5bb9\u4f20\u8f93\u7684\u5927\u5c0f\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">3.\u7cbe\u7b80\u5b57\u6bb5\u9664\u4e86\u901a\u8fc7\u51cf\u5c11\u4e0d\u5fc5\u8981\u7684\u5b57\u6bb5\u4f20\u8f93\u4e4b\u5916\uff0c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6539\u53d8\u6570\u636e\u7ed3\u6784\uff0c\u6570\u636e\u7c7b\u578b\u6765\u5b9e\u73b0\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u6570\u636e\u4f20\u8f93\u683c\u5f0f<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5e38\u7528\u7684\u5982JSON\uff0c\u8bed\u6cd5\u7b80\u5355\uff0c\u76f8\u6bd4XML\u6765\u8bf4\u4f20\u8f93\u4f53\u79ef\u66f4\u5c0f\uff0c\u89e3\u6790\u66f4\u5feb\uff0c\u4f46\u5982\u679c\u9700\u8981\u9891\u7e41\u4f20\u8f93\u5927\u91cf\u6570\u636e\u65f6\uff0c\u4f7f\u7528protobuf\u5219\u66f4\u4f1a\u66f4\u52a0\u9ad8\u6548\uff0c\u56e0\u4e3a\u5176\u91c7\u7528\u7ed3\u6784\u5316\u7684\u6570\u636e\u63cf\u8ff0\u8bed\u8a00\uff0c\u5e76\u4f7f\u7528\u4e8c\u8fdb\u5236\u7f16\u7801\uff0c\u56e0\u4e3a\u4f53\u79ef\u66f4\u5c0f\uff0c\u901f\u5ea6\u66f4\u5feb\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u538b\u7f29<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5e38\u89c1\u7684\u6570\u636e\u538b\u7f29\u65b9\u5f0f\u5982\uff1aGZIP\u3001zlib\uff0c\u800czip\u5e38\u7528\u4e8e\u6587\u4ef6\u538b\u7f29\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u501f\u52a9Hutool\u5de5\u5177\u5305\uff0c\u53ef\u4ee5\u770b\u4e0b\u538b\u7f29\u7684\u6548\u679c<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">gzip\u538b\u7f29<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(209, 154, 102);\">StringBuilder<\/span><span style=\"color: rgb(209, 154, 102);\">sb<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">StringBuilder<\/span>();<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">1000<\/span>;i++){sb.append(i);}System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u538b\u7f29\u524d\uff1a\"<\/span>+sb.toString().getBytes().length);<span style=\"color: rgb(209, 154, 102);\">byte<\/span>[]compressedBytes=ZipUtil.gzip(sb.toString(),CharsetUtil.UTF_8);System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u538b\u7f29\u540e\uff1a\"<\/span>+compressedBytes.length);<span style=\"color: rgb(209, 154, 102);\">String<\/span><span style=\"color: rgb(209, 154, 102);\">str<\/span>=ZipUtil.unGzip(compressedBytes,CharsetUtil.UTF_8);System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u538b\u7f29\u8fd8\u539f\uff1a\"<\/span>+str.getBytes().length);<\/code><\/pre>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">\u538b\u7f29\u524d\uff1a<span style=\"color: rgb(209, 154, 102);\">2890<\/span>\u538b\u7f29\u540e\uff1a<span style=\"color: rgb(209, 154, 102);\">1474<\/span>\u538b\u7f29\u8fd8\u539f\uff1a<span style=\"color: rgb(209, 154, 102);\">2890<\/span><\/code><\/pre>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">zlib\u538b\u7f29<\/p>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\"><span style=\"color: rgb(209, 154, 102);\">StringBuilder<\/span><span style=\"color: rgb(209, 154, 102);\">sb<\/span>=<span style=\"color: rgb(198, 120, 221);\">new<\/span><span style=\"color: rgb(230, 192, 123);\">StringBuilder<\/span>();<span style=\"color: rgb(198, 120, 221);\">for<\/span>(<span style=\"color: rgb(209, 154, 102);\">int<\/span><span style=\"color: rgb(209, 154, 102);\">i<\/span>=<span style=\"color: rgb(209, 154, 102);\">0<\/span>;i&lt;<span style=\"color: rgb(209, 154, 102);\">1000<\/span>;i++){sb.append(i);}System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u538b\u7f29\u524d\uff1a\"<\/span>+sb.toString().getBytes().length);<span style=\"color: rgb(209, 154, 102);\">byte<\/span>[]compressedBytes=ZipUtil.zlib(sb.toString(),CharsetUtil.UTF_8,<span style=\"color: rgb(209, 154, 102);\">1<\/span>);System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u538b\u7f29\u540e\uff1a\"<\/span>+compressedBytes.length);<span style=\"color: rgb(209, 154, 102);\">String<\/span><span style=\"color: rgb(209, 154, 102);\">str<\/span>=ZipUtil.unZlib(compressedBytes,CharsetUtil.UTF_8);System.out.println(<span style=\"color: rgb(152, 195, 121);\">\"\u538b\u7f29\u8fd8\u539f\uff1a\"<\/span>+str.getBytes().length);<\/code><\/pre>\n<pre style=\"color: rgb(171, 178, 191);background: rgb(40, 44, 52);font-size: 14px;letter-spacing: normal;text-align: left;line-height: 1.5;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;overflow-x: auto;border-radius: 8px;margin: 10px 8px;\"><span style=\"padding: initial;display: block;height: 25px;background-color: transparent;background-image: url('https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222559837.jpeg');background-repeat: no-repeat;background-position: 14px 10px !important;background-size: 40px !important;\"><\/span><code style=\"font-family: Menlo, &#39;Operator Mono&#39;, Consolas, Monaco, monospace;display: -webkit-box;padding: 0.5em 1em 1em;overflow-x: auto;line-height: 1.75;font-size: 12px;white-space-collapse: collapse;\">\u538b\u7f29\u524d\uff1a<span style=\"color: rgb(209, 154, 102);\">2890<\/span>\u538b\u7f29\u540e\uff1a<span style=\"color: rgb(209, 154, 102);\">1518<\/span>\u538b\u7f29\u8fd8\u539f\uff1a<span style=\"color: rgb(209, 154, 102);\">2890<\/span><\/code><\/pre>\n<h1 style=\"letter-spacing: normal;text-align: center;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 17.1px;font-weight: bold;display: table;margin: 2em auto 1em;padding-right: 1em;padding-left: 1em;border-bottom: 2px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">12. \u51cf\u5c11\u670d\u52a1\u4e4b\u95f4\u7684\u4f9d\u8d56<\/h1>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u4f9d\u8d56\u8d8a\u591a\uff0c\u4e0d\u4f46\u4f1a\u7ed9\u670d\u52a1\u7684\u7a33\u5b9a\u6027\u3001\u53ef\u9760\u6027\u9020\u6210\u5f71\u54cd\uff0c\u540c\u65f6\u4e5f\u4f1a\u6210\u4e3a\u6027\u80fd\u63d0\u5347\u7684\u74f6\u9888\uff0c\u56e0\u6b64\u6211\u4eec\u5728\u8bbe\u8ba1\u4e4b\u521d\u5c31\u5e94\u5f53\u5145\u5206\u8003\u8651\u5230\u8fd9\u4e2a\u95ee\u9898\uff0c\u901a\u8fc7\u5408\u7406\u7684\u624b\u6bb5\u6765\u51cf\u5c11\u670d\u52a1\u4e4b\u95f4\u7684\u4f9d\u8d56\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u94fe\u8def\u6cbb\u7406<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u901a\u8fc7\u5408\u7406\u7684\u5fae\u670d\u52a1\u5212\u5206\uff0c\u53ef\u4ee5\u6709\u6548\u7684\u51cf\u5c11\u94fe\u8def\u4e0a\u7684\u4f9d\u8d56\uff0c\u94fe\u8def\u8c03\u7528\u4e4b\u95f4\u8981\u907f\u514d\u51fa\u73b0\u91cd\u590d\u8c03\u7528\uff0c\u5faa\u73af\u4f9d\u8d56\uff0c\u4ee5\u53ca\u4e0a\u3001\u4e0b\u5c42\u7ea7\u4e92\u76f8\u8c03\u7528\u7684\u60c5\u51b5\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u91cd\u590d\u8c03\u7528<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100036998\" data-ratio=\"0.8581560283687943\" data-type=\"other\" data-w=\"846\"  src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100036998\" data-ratio=\"0.8581560283687943\" data-type=\"other\" data-w=\"846\"  src=\"\"  \/><\/noscript><\/figure>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5faa\u73af\u4f9d\u8d56<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100036999\" data-ratio=\"0.9883268482490273\" data-type=\"other\" data-w=\"514\"  src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100036999\" data-ratio=\"0.9883268482490273\" data-type=\"other\" data-w=\"514\"  src=\"\"  \/><\/noscript><\/figure>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u670d\u52a1\u4e0a\u3001\u4e0b\u5c42\u7ea7\u6df7\u4e71\uff0c\u4e92\u76f8\u8c03\u7528<\/p>\n<figure style=\"letter-spacing: normal;text-align: left;line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;color: rgb(63, 63, 63);\"><img decoding=\"async\" class=\"rich_pages wxw-img lazyload\" data-imgfileid=\"100037003\" data-ratio=\"0.9977628635346756\" data-type=\"other\" data-w=\"447\"  src=\"\"  \/><noscript><img decoding=\"async\" class=\"rich_pages wxw-img\" data-imgfileid=\"100037003\" data-ratio=\"0.9977628635346756\" data-type=\"other\" data-w=\"447\"  src=\"\"  \/><\/noscript><\/figure>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u6570\u636e\u5197\u4f59<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6570\u636e\u5197\u4f59\u662f\u6307\u5c06\u975e\u81ea\u8eab\u7ef4\u62a4\u7684\u6570\u636e\u901a\u8fc7\u67d0\u79cd\u624b\u6bb5\u4fdd\u5b58\u4e0b\u6765\uff0c\u4ee5\u4fbf\u5728\u4e4b\u540e\u4f7f\u7528\u65f6\u907f\u514d\u591a\u6b21\u53d1\u8d77\u6570\u636e\u8bf7\u6c42\uff0c\u4ece\u800c\u5b9e\u73b0\u51cf\u5c11\u670d\u52a1\u4f9d\u8d56\u7684\u624b\u6bb5\u3002<\/p>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5e38\u89c1\u7684\u65b9\u5f0f\u5982\uff1a\u901a\u7528\u7684\u57fa\u7840\u6570\u636e\uff0c\u5b57\u5178\u6570\u636e\u7b49\u5404\u4e2a\u9700\u6c42\u65b9\u53ef\u590d\u5236\u4e00\u4efd\u5b58\u5728\u672c\u5730\uff1b\u5efa\u7acb\u5bbd\u8868\uff0c\u5197\u4f59\u90e8\u5206\u6570\u636e\uff0c\u51cf\u5c11\u5173\u8054\u67e5\u8be2\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u7ed3\u679c\u7f13\u5b58<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u5c06\u9700\u8981\u9891\u7e41\u4f7f\u7528\u7684\u7ed3\u679c\u5b58\u50a8\u5728\u7f13\u5b58\u670d\u52a1\u4e2d\uff0c\u4e5f\u662f\u6709\u6548\u51cf\u5c11\u670d\u52a1\u4f9d\u8d56\u7684\u65b9\u5f0f\u4e4b\u4e00\u3002<\/p>\n<h3 style=\"letter-spacing: normal;text-align: left;line-height: 1.2;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;font-weight: bold;margin-top: 2em;margin-right: 8px;margin-bottom: 0.75em;padding-left: 8px;border-left: 3px solid rgb(250, 81, 81);color: rgb(63, 63, 63);\">\u6d88\u606f\u961f\u5217<\/h3>\n<p style=\"line-height: 1.75;font-family: -apple-system-font, BlinkMacSystemFont, &#39;Helvetica Neue&#39;, &#39;PingFang SC&#39;, &#39;Hiragino Sans GB&#39;, &#39;Microsoft YaHei UI&#39;, &#39;Microsoft YaHei&#39;, Arial, sans-serif;font-size: 15px;margin: 1.5em 8px;letter-spacing: 0.1em;color: rgb(63, 63, 63);\">\u6d88\u606f\u961f\u5217\u5929\u7136\u5c31\u6709\u7b80\u5316\u7cfb\u7edf\u590d\u6742\u6027\u7684\u4f5c\u7528\uff0c\u5b83\u901a\u8fc7\u5f02\u6b65\u7684\u65b9\u5f0f\u5c06\u4efb\u52a1\u4e0e\u4efb\u52a1\u4e4b\u95f4\u7684\u5173\u7cfb\u8fdb\u884c\u89e3\u8026\uff0c\u4e5f\u5c31\u8fbe\u5230\u4e86\u51cf\u5c11\u670d\u52a1\u4e4b\u95f4\u4f9d\u8d56\u7684\u6548\u679c\u3002<\/p>\n<section data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\">\n<section data-tool=\"mdnice\u7f16\u8f91\u5668\" data-website=\"https:\/\/www.mdnice.com\" style=\"margin-bottom: 0px;padding-right: 10px;padding-left: 10px;outline: 0px;color: rgb(0, 0, 0);font-family: Optima, &quot;Microsoft YaHei&quot;, PingFangSC-regular, serif;font-size: 16px;letter-spacing: 0em;text-align: left;word-spacing: 0em;text-wrap: wrap;background: none 0% 0% \/ auto no-repeat scroll padding-box border-box rgb(255, 255, 255);width: auto;line-height: 1.5em;word-break: break-word;visibility: visible;\">\n<p data-tool=\"mdnice\u7f16\u8f91\u5668\" style=\"padding-top: 8px;padding-bottom: 8px;outline: 0px;color: rgb(89, 89, 89);font-size: 15px;line-height: 1.8em;letter-spacing: 0.04em;text-indent: 0em;text-align: center;\"><span style=\"outline: 0px;font-weight: bolder;letter-spacing: 0.6px;background-image: none;background-position: 0% 0%;background-size: auto;background-repeat: no-repeat;background-attachment: scroll;background-origin: padding-box;background-clip: border-box;color: rgb(53, 179, 120);width: auto;height: auto;border-style: none;border-width: 3px;border-color: rgba(0, 0, 0, 0.4);border-radius: 0px;\">- End-<\/span><\/p>\n<\/section>\n<p style=\"margin-bottom: 0px;outline: 0px;color: rgb(0, 0, 0);font-size: 16px;letter-spacing: normal;text-align: left;text-wrap: wrap;font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;word-spacing: 0.8px;background-color: rgb(255, 255, 255);\">\n<p style=\"margin-bottom: 0px;outline: 0px;font-size: 16px;text-wrap: wrap;color: rgb(53, 53, 53);word-spacing: 0.8px;letter-spacing: 0.544px;background-color: rgb(255, 255, 255);font-family: system-ui, -apple-system, system-ui, &quot;Helvetica Neue&quot;, &quot;PingFang SC&quot;, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei UI&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;text-align: center;\"><img decoding=\"async\" class=\"rich_pages wxw-img __bg_gif lazyload\" data-galleryid=\"\" data-imgfileid=\"100037004\" data-ratio=\"0.5763888888888888\" data-type=\"gif\" data-w=\"288\"  style=\"outline: 0px;border-style: none;color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;letter-spacing: normal;visibility: visible !important;width: 287.969px !important;\" data-src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222628668.gif\" 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 __bg_gif\" data-galleryid=\"\" data-imgfileid=\"100037004\" data-ratio=\"0.5763888888888888\" data-type=\"gif\" data-w=\"288\"  style=\"outline: 0px;border-style: none;color: rgb(0, 0, 0);font-family: Optima-Regular, Optima, PingFangSC-light, PingFangTC-light, &quot;PingFang SC&quot;, Cambria, Cochin, Georgia, Times, &quot;Times New Roman&quot;, serif;letter-spacing: normal;visibility: visible !important;width: 287.969px !important;\" src=\"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222628668.gif\"  \/><\/noscript><\/p>\n<\/section>\n<p style=\"display: none;\"><mp-style-type data-value=\"3\"><\/mp-style-type><\/p>\n<blockquote>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u6e90\u4e8e\u5fae\u4fe1\u516c\u4f17\u53f7:                 JAVA\u65e5\u77e5\u5f55              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>1. \u5e76\u884c\u5904\u7406 \u7b80\u8981\u8bf4\u660e \u4e3e\u4e2a\u4f8b\u5b50\uff1a\u5728\u4ef7\u683c\u67e5\u8be2\u94fe\u8def\u4e2d\uff0c\u6211\u4eec\u9700\u8981\u83b7\u53d6\u591a\u79cd\u72ec\u7acb\u7684\u4ef7\u683c\u914d\u7f6e\u9879\u4fe1\u606f\uff0c\u5982\u57fa\u7840\u4ef7\u3001\u6298\u6263\u4ef7\u3001\u5546\u6237\u6d3b\u52a8\u4ef7\u3001\u5e73\u53f0\u6d3b\u52a8 &#8230;<\/p>\n","protected":false},"author":1,"featured_media":5765,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[2],"tags":[],"class_list":["post-5803","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222603274-150x150.jpeg","content_first_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222613481.png","post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222603274-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222603274.jpeg","post_frist_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222613481.png","post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222603274-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222603274.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222603274.jpeg","post_all_images":[{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222613481.png","id":"image0"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222613481.png","id":"image1"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222618261.png","id":"image2"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222618261.png","id":"image3"},{"imagesurl":"","id":"image4"},{"imagesurl":"","id":"image5"},{"imagesurl":"","id":"image6"},{"imagesurl":"","id":"image7"},{"imagesurl":"","id":"image8"},{"imagesurl":"","id":"image9"},{"imagesurl":"","id":"image10"},{"imagesurl":"","id":"image11"},{"imagesurl":"","id":"image12"},{"imagesurl":"","id":"image13"},{"imagesurl":"","id":"image14"},{"imagesurl":"","id":"image15"},{"imagesurl":"","id":"image16"},{"imagesurl":"","id":"image17"},{"imagesurl":"","id":"image18"},{"imagesurl":"","id":"image19"},{"imagesurl":"","id":"image20"},{"imagesurl":"","id":"image21"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222628668.gif","id":"image22"},{"imagesurl":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/08\/20240801222628668.gif","id":"image23"}],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"Java","post_date":"2024-08-01","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":377,"next_post_id":5843,"next_post_title":"Vue\u6253\u5305\u6587\u4ef6dist\u653e\u5728SpringBoot\u9879\u76ee\u4e0b\u8fd0\u884c\uff08\u6b63\u786e\u5b9e\u73b0\u5168\u8fc7\u7a0b\uff09","previous_post_id":3808,"previous_post_title":"\u5982\u4f55\u5feb\u901f\u5b9a\u4f4d\u548c\u5904\u7406\u7ebf\u4e0aOOM","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5803","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/comments?post=5803"}],"version-history":[{"count":1,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5803\/revisions"}],"predecessor-version":[{"id":6269,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/5803\/revisions\/6269"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/5765"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=5803"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=5803"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=5803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}