{"id":4092,"date":"2024-04-21T09:02:39","date_gmt":"2024-04-21T01:02:39","guid":{"rendered":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%9d%a2%e8%af%95\/%e5%85%b3%e4%ba%8ejava%e4%b8%ad%e6%ad%bb%e9%94%81%e7%9a%84%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%8c%e7%9c%8b%e5%ae%8c%e8%bf%99%e4%b8%80%e7%af%87%e5%b0%b1%e5%a4%9f%e4%ba%86\/"},"modified":"2024-04-21T09:02:39","modified_gmt":"2024-04-21T01:02:39","slug":"%e5%85%b3%e4%ba%8ejava%e4%b8%ad%e6%ad%bb%e9%94%81%e7%9a%84%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%8c%e7%9c%8b%e5%ae%8c%e8%bf%99%e4%b8%80%e7%af%87%e5%b0%b1%e5%a4%9f%e4%ba%86","status":"publish","type":"post","link":"https:\/\/xinchewhd.com.cn\/index.php\/%e9%9d%a2%e8%af%95\/%e5%85%b3%e4%ba%8ejava%e4%b8%ad%e6%ad%bb%e9%94%81%e7%9a%84%e9%9d%a2%e8%af%95%e9%a2%98%ef%bc%8c%e7%9c%8b%e5%ae%8c%e8%bf%99%e4%b8%80%e7%af%87%e5%b0%b1%e5%a4%9f%e4%ba%86\/","title":{"rendered":"\u5173\u4e8eJava\u4e2d\u6b7b\u9501\u7684\u9762\u8bd5\u9898\uff0c\u770b\u5b8c\u8fd9\u4e00\u7bc7\u5c31\u591f\u4e86"},"content":{"rendered":"<div class='wxsyncmain'>\n<p data-v-md-line=\"3\"><span style=\"font-size: 20px;\"><strong>\u4ec0\u4e48\u662fJava\u6b7b\u9501\uff1f<\/strong><\/span><\/p>\n<p data-v-md-line=\"1\"><span style=\"font-size: 15px;\">\u5728Java\u4e2d\uff0c\u6b7b\u9501\u662f\u6307\u4e24\u4e2a\u6216\u591a\u4e2a\u7ebf\u7a0b\u4e92\u76f8\u6301\u6709\u5bf9\u65b9\u6240\u9700\u7684\u8d44\u6e90\uff0c\u5e76\u56e0\u6b64\u5904\u4e8e\u6c38\u4e45\u963b\u585e\u7684\u72b6\u6001\u3002\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\u5728\u6bcf\u4e2a\u7ebf\u7a0b\u90fd\u5728\u7b49\u5f85\u53e6\u4e00\u4e2a\u7ebf\u7a0b\u91ca\u653e\u5b83\u6240\u9700\u7684\u8d44\u6e90\u65f6\uff0c\u5bfc\u81f4\u6240\u6709\u6d89\u53ca\u7684\u7ebf\u7a0b\u90fd\u65e0\u6cd5\u7ee7\u7eed\u6267\u884c\u4e0b\u53bb\u3002<\/span><\/p>\n<p data-v-md-line=\"3\"><span style=\"font-size: 15px;\">\u6b7b\u9501\u4ea7\u751f\u7684\u539f\u56e0\u901a\u5e38\u53ef\u4ee5\u5f52\u7ed3\u4e3a\u4ee5\u4e0b\u56db\u4e2a\u5fc5\u8981\u6761\u4ef6\uff1a<\/span><\/p>\n<ol data-v-md-line=\"5\" class=\"list-paddingleft-1\">\n<li>\n<p><strong><span style=\"font-size: 15px;\">\u4e92\u65a5\u6761\u4ef6<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u8d44\u6e90\u53ea\u80fd\u88ab\u4e00\u4e2a\u7ebf\u7a0b\u5360\u7528\uff0c\u5982\u679c\u5176\u4ed6\u7ebf\u7a0b\u60f3\u8981\u4f7f\u7528\uff0c\u5c31\u5fc5\u987b\u7b49\u5f85\u8be5\u7ebf\u7a0b\u91ca\u653e\u8d44\u6e90\u3002<\/span><\/p>\n<\/li>\n<li>\n<p><strong><span style=\"font-size: 15px;\">\u8bf7\u6c42\u4e0e\u4fdd\u6301\u6761\u4ef6<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u7ebf\u7a0b\u5df2\u7ecf\u6301\u6709\u81f3\u5c11\u4e00\u4e2a\u8d44\u6e90\uff0c\u4f46\u53c8\u63d0\u51fa\u4e86\u65b0\u7684\u8d44\u6e90\u8bf7\u6c42\uff0c\u800c\u65b0\u7684\u8d44\u6e90\u53ef\u80fd\u88ab\u5176\u4ed6\u7ebf\u7a0b\u5360\u7528\uff0c\u5bfc\u81f4\u5faa\u73af\u7b49\u5f85\u3002<\/span><\/p>\n<\/li>\n<li>\n<p><strong><span style=\"font-size: 15px;\">\u4e0d\u5265\u593a\u6761\u4ef6<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u5df2\u83b7\u5f97\u7684\u8d44\u6e90\u5728\u672a\u4f7f\u7528\u5b8c\u4e4b\u524d\u4e0d\u80fd\u88ab\u5176\u4ed6\u7ebf\u7a0b\u62a2\u5360\uff0c\u53ea\u80fd\u7531\u6301\u6709\u5b83\u7684\u7ebf\u7a0b\u81ea\u884c\u91ca\u653e\u3002<\/span><\/p>\n<\/li>\n<li>\n<p><strong><span style=\"font-size: 15px;\">\u73af\u8def\u7b49\u5f85\u6761\u4ef6<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u82e5\u5e72\u7ebf\u7a0b\u5f62\u6210\u4e00\u79cd\u5934\u5c3e\u76f8\u63a5\u7684\u5faa\u73af\u7b49\u5f85\u8d44\u6e90\u7684\u5173\u7cfb\uff0c\u6bcf\u4e2a\u7ebf\u7a0b\u90fd\u5728\u7b49\u5f85\u4e0b\u4e00\u4e2a\u7ebf\u7a0b\u6240\u6301\u6709\u7684\u8d44\u6e90\u3002<\/span><\/p>\n<\/li>\n<\/ol>\n<p data-v-md-line=\"10\"><span style=\"font-size: 15px;\">\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\u8bf4\u660eJava\u6b7b\u9501\u7684\u60c5\u51b5\uff1a<\/span><\/p>\n<section class=\"code-snippet__fix code-snippet__js\">\n<ul class=\"code-snippet__line-index code-snippet__js\">\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<li><\/li>\n<\/ul>\n<pre class=\"code-snippet__js\" data-lang=\"cs\"><code><span class=\"code-snippet_outer\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">class<\/span> <span class=\"code-snippet__title\">DeadlockExample<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">private<\/span> <span class=\"code-snippet__keyword\">static<\/span> Object resource1 = <span class=\"code-snippet__keyword\">new<\/span> Object();<\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__keyword\">private<\/span> <span class=\"code-snippet__keyword\">static<\/span> Object resource2 = <span class=\"code-snippet__keyword\">new<\/span> Object();<\/span><\/code><code><span class=\"code-snippet_outer\"><\/span><\/code><code><span class=\"code-snippet_outer\">    <span class=\"code-snippet__function\"><span class=\"code-snippet__keyword\">public<\/span> <span class=\"code-snippet__keyword\">static<\/span> <span class=\"code-snippet__keyword\">void<\/span> <span class=\"code-snippet__title\">main<\/span>(<span class=\"code-snippet__params\">String[] args<\/span>)<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">        Thread thread1 = <span class=\"code-snippet__keyword\">new<\/span> Thread(() -&gt; {<\/span><\/code><code><span class=\"code-snippet_outer\">            synchronized (resource1) {<\/span><\/code><code><span class=\"code-snippet_outer\">                System.<span class=\"code-snippet__keyword\">out<\/span>.println(<span class=\"code-snippet__string\">\"Thread 1: Locked resource 1\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">                <span class=\"code-snippet__keyword\">try<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">                    Thread.sleep(<span class=\"code-snippet__number\">100<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">                } <span class=\"code-snippet__keyword\">catch<\/span> (InterruptedException e) {}<\/span><\/code><code><span class=\"code-snippet_outer\">                synchronized (resource2) {<\/span><\/code><code><span class=\"code-snippet_outer\">                    System.<span class=\"code-snippet__keyword\">out<\/span>.println(<span class=\"code-snippet__string\">\"Thread 1: Locked resource 2\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">                }<\/span><\/code><code><span class=\"code-snippet_outer\">            }<\/span><\/code><code><span class=\"code-snippet_outer\">        });<\/span><\/code><code><span class=\"code-snippet_outer\"><\/span><\/code><code><span class=\"code-snippet_outer\">        Thread thread2 = <span class=\"code-snippet__keyword\">new<\/span> Thread(() -&gt; {<\/span><\/code><code><span class=\"code-snippet_outer\">            synchronized (resource2) {<\/span><\/code><code><span class=\"code-snippet_outer\">                System.<span class=\"code-snippet__keyword\">out<\/span>.println(<span class=\"code-snippet__string\">\"Thread 2: Locked resource 2\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">                <span class=\"code-snippet__keyword\">try<\/span> {<\/span><\/code><code><span class=\"code-snippet_outer\">                    Thread.sleep(<span class=\"code-snippet__number\">100<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">                } <span class=\"code-snippet__keyword\">catch<\/span> (InterruptedException e) {}<\/span><\/code><code><span class=\"code-snippet_outer\">                synchronized (resource1) {<\/span><\/code><code><span class=\"code-snippet_outer\">                    System.<span class=\"code-snippet__keyword\">out<\/span>.println(<span class=\"code-snippet__string\">\"Thread 2: Locked resource 1\"<\/span>);<\/span><\/code><code><span class=\"code-snippet_outer\">                }<\/span><\/code><code><span class=\"code-snippet_outer\">            }<\/span><\/code><code><span class=\"code-snippet_outer\">        });<\/span><\/code><code><span class=\"code-snippet_outer\"><\/span><\/code><code><span class=\"code-snippet_outer\">        thread1.start();<\/span><\/code><code><span class=\"code-snippet_outer\">        thread2.start();<\/span><\/code><code><span class=\"code-snippet_outer\">    }<\/span><\/code><code><span class=\"code-snippet_outer\">}<\/span><\/code><\/pre>\n<\/section>\n<p><span style=\"font-size: 15px;\">\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0cthread1\u6301\u6709resource1\u5e76\u7b49\u5f85\u83b7\u53d6resource2\uff0c\u800cthread2\u6301\u6709resource2\u5e76\u7b49\u5f85\u83b7\u53d6resource1\uff0c\u8fd9\u5bfc\u81f4\u4e24\u4e2a\u7ebf\u7a0b\u9677\u5165\u6b7b\u9501\u72b6\u6001\u3002<\/span><\/p>\n<p data-v-md-line=\"12\"><span style=\"font-size: 20px;\"><strong>2\u3001\u5982\u4f55\u907f\u514d\u6b7b\u9501\uff1f<\/strong><\/span><\/p>\n<p data-v-md-line=\"1\"><span style=\"font-size: 15px;\">\u5728Java\u4e2d\uff0c\u53ef\u4ee5\u91c7\u53d6\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\u6765\u907f\u514d\u6b7b\u9501\uff1a<\/span><\/p>\n<ol data-v-md-line=\"3\" class=\"list-paddingleft-1\" style=\"\">\n<li>\n<p data-v-md-line=\"3\"><strong><span style=\"font-size: 15px;\">\u907f\u514d\u5d4c\u5957\u9501<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u5c3d\u91cf\u907f\u514d\u5728\u6301\u6709\u4e00\u4e2a\u9501\u7684\u60c5\u51b5\u4e0b\u53bb\u8bf7\u6c42\u53e6\u4e00\u4e2a\u9501\u3002\u5982\u679c\u65e0\u6cd5\u907f\u514d\u5d4c\u5957\u9501\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u901a\u8fc7\u91cd\u6784\u4ee3\u7801\u6765\u6d88\u9664\u5d4c\u5957\u9501\u7684\u60c5\u51b5\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"5\"><strong><span style=\"font-size: 15px;\">\u6309\u5e8f\u7533\u8bf7\u8d44\u6e90<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u6240\u6709\u7ebf\u7a0b\u5fc5\u987b\u4ee5\u76f8\u540c\u7684\u987a\u5e8f\u8bf7\u6c42\u8d44\u6e90\u3002\u8fd9\u6837\u53ef\u4ee5\u907f\u514d\u4e0d\u540c\u7ebf\u7a0b\u56e0\u8bf7\u6c42\u8d44\u6e90\u7684\u987a\u5e8f\u4e0d\u540c\u800c\u53d1\u751f\u6b7b\u9501\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"7\"><strong><span style=\"font-size: 15px;\">\u4f7f\u7528\u8d85\u65f6\u673a\u5236<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u5728\u83b7\u53d6\u9501\u7684\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\uff0c\u5982\u679c\u8d85\u8fc7\u4e00\u5b9a\u65f6\u95f4\u8fd8\u672a\u83b7\u53d6\u5230\u6240\u9700\u7684\u9501\uff0c\u5c31\u653e\u5f03\u5f53\u524d\u7684\u8d44\u6e90\u5e76\u91ca\u653e\u5df2\u7ecf\u6301\u6709\u7684\u8d44\u6e90\uff0c\u7136\u540e\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u518d\u91cd\u65b0\u5c1d\u8bd5\u3002\u8fd9\u53ef\u4ee5\u9632\u6b62\u7ebf\u7a0b\u957f\u65f6\u95f4\u7b49\u5f85\u800c\u5bfc\u81f4\u7684\u6b7b\u9501\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"9\"><strong><span style=\"font-size: 15px;\">\u4f7f\u7528tryLock()\u65b9\u6cd5<\/span><\/strong><span style=\"font-size: 15px;\">\uff1aReentrantLock\u7c7b\u63d0\u4f9b\u4e86tryLock()\u65b9\u6cd5\uff0c\u5b83\u53ef\u4ee5\u5728\u5c1d\u8bd5\u83b7\u53d6\u9501\u65f6\u8bbe\u5b9a\u4e00\u4e2a\u8d85\u65f6\u65f6\u95f4\uff0c\u5982\u679c\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u672a\u80fd\u83b7\u53d6\u9501\uff0c\u5219\u8fd4\u56defalse\uff0c\u53ef\u4ee5\u6839\u636e\u8fd4\u56de\u503c\u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"11\"><strong><span style=\"font-size: 15px;\">\u4f7f\u7528\u8d44\u6e90\u5206\u914d\u56fe<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u53ef\u4ee5\u4f7f\u7528\u8d44\u6e90\u5206\u914d\u56fe\u6765\u68c0\u6d4b\u6f5c\u5728\u7684\u6b7b\u9501\u60c5\u51b5\uff0c\u901a\u8fc7\u8d44\u6e90\u5206\u914d\u56fe\u53ef\u4ee5\u6e05\u6670\u5730\u770b\u51fa\u662f\u5426\u5b58\u5728\u5faa\u73af\u7b49\u5f85\u7684\u60c5\u51b5\uff0c\u4ece\u800c\u53ca\u65f6\u91c7\u53d6\u63aa\u65bd\u907f\u514d\u6b7b\u9501\u7684\u53d1\u751f\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"13\"><strong><span style=\"font-size: 15px;\">\u4f18\u5316\u8d44\u6e90\u7ba1\u7406<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u5bf9\u4e8e\u4e00\u4e9b\u5fc5\u987b\u4e32\u884c\u8bbf\u95ee\u7684\u8d44\u6e90\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u5355\u4f8b\u6a21\u5f0f\u6216\u8005\u8fde\u63a5\u6c60\u7b49\u673a\u5236\uff0c\u51cf\u5c11\u8d44\u6e90\u7684\u7ade\u4e89\u548c\u51b2\u7a81\uff0c\u4ece\u800c\u964d\u4f4e\u6b7b\u9501\u7684\u98ce\u9669\u3002<\/span><\/p>\n<\/li>\n<\/ol>\n<p data-v-md-line=\"15\"><span style=\"font-size: 15px;\">\u603b\u4e4b\uff0c\u907f\u514d\u6b7b\u9501\u662f\u4e00\u4e2a\u9700\u8981\u7efc\u5408\u8003\u8651\u591a\u65b9\u9762\u56e0\u7d20\u7684\u95ee\u9898\uff0c\u9700\u8981\u5728\u8bbe\u8ba1\u3001\u5b9e\u73b0\u548c\u8c03\u4f18\u9636\u6bb5\u90fd\u8981\u6709\u610f\u8bc6\u5730\u907f\u514d\u6f5c\u5728\u7684\u6b7b\u9501\u98ce\u9669\u3002<\/span><\/p>\n<p data-v-md-line=\"15\"><strong style=\"font-size: 20px;letter-spacing: 0.034em;\">3\u3001\u5982\u4f55\u68c0\u6d4b\u548c\u89e3\u51b3\u6b7b\u9501\uff1f<\/strong><\/p>\n<ol data-v-md-line=\"3\" class=\"list-paddingleft-1\">\n<p data-v-md-line=\"1\"><span style=\"font-size: 15px;\">\u5728Java\u4e2d\uff0c\u53ef\u4ee5\u91c7\u53d6\u4e00\u4e9b\u65b9\u6cd5\u6765\u68c0\u6d4b\u548c\u89e3\u51b3\u6b7b\u9501\u95ee\u9898\uff1a<\/span><\/p>\n<h3 data-v-md-heading=\"\u68c0\u6d4b\u6b7b\u9501\" data-v-md-line=\"3\" style=\"margin-top: 16px;margin-bottom: 16px;\"><span style=\"font-size: 16px;\"><strong>\u68c0\u6d4b\u6b7b\u9501\uff1a<\/strong><\/span><span style=\"font-size: 15px;\"><\/span><\/h3>\n<ol data-v-md-line=\"5\" class=\"list-paddingleft-1\" style=\"list-style-type: lower-alpha;\">\n<li>\n<p data-v-md-line=\"5\"><strong><span style=\"font-size: 15px;\">\u4f7f\u7528\u5de5\u5177<\/span><\/strong><span style=\"font-size: 15px;\">\uff1aJava\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5de5\u5177\u6765\u5e2e\u52a9\u68c0\u6d4b\u6b7b\u9501\uff0c\u4f8b\u5982JConsole\u3001VisualVM\u7b49\uff0c\u8fd9\u4e9b\u5de5\u5177\u53ef\u4ee5\u7528\u4e8e\u76d1\u63a7\u7ebf\u7a0b\u548c\u9501\u7684\u60c5\u51b5\uff0c\u4ece\u800c\u53ca\u65f6\u53d1\u73b0\u6f5c\u5728\u7684\u6b7b\u9501\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"7\"><strong><span style=\"font-size: 15px;\">\u7f16\u7a0b\u65b9\u5f0f<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u7a0b\u5e8f\u6765\u68c0\u6d4b\u6b7b\u9501\u3002\u4e00\u79cd\u5e38\u89c1\u7684\u65b9\u5f0f\u662f\u4f7f\u7528\u7ebf\u7a0b\u8f6c\u50a8\uff08Thread Dump\uff09\u6765\u67e5\u770b\u7ebf\u7a0b\u7684\u72b6\u6001\u4ee5\u53ca\u5b83\u4eec\u6301\u6709\u7684\u9501\u4fe1\u606f\uff0c\u4ece\u800c\u53d1\u73b0\u53ef\u80fd\u5b58\u5728\u7684\u6b7b\u9501\u60c5\u51b5\u3002<\/span><\/p>\n<\/li>\n<\/ol>\n<h3 data-v-md-heading=\"\u89e3\u51b3\u6b7b\u9501\" data-v-md-line=\"9\" style=\"margin-top: 16px;margin-bottom: 16px;\"><span style=\"font-size: 16px;\"><strong>\u89e3\u51b3\u6b7b\u9501\uff1a<\/strong><\/span><\/h3>\n<ol data-v-md-line=\"11\" class=\"list-paddingleft-1\" style=\"list-style-type: lower-alpha;\">\n<li>\n<p data-v-md-line=\"11\"><strong><span style=\"font-size: 15px;\">\u6253\u7834\u5faa\u73af\u7b49\u5f85<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u901a\u8fc7\u5bf9\u8d44\u6e90\u8fdb\u884c\u7f16\u53f7\uff0c\u8981\u6c42\u6240\u6709\u7ebf\u7a0b\u6309\u7167\u7f16\u53f7\u9012\u589e\u7684\u987a\u5e8f\u7533\u8bf7\u8d44\u6e90\uff0c\u53ef\u4ee5\u6709\u6548\u6253\u7834\u5faa\u73af\u7b49\u5f85\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"13\"><strong><span style=\"font-size: 15px;\">\u4f7f\u7528\u8d85\u65f6\u673a\u5236<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u5728\u83b7\u53d6\u9501\u7684\u8fc7\u7a0b\u4e2d\u8bbe\u7f6e\u8d85\u65f6\u65f6\u95f4\uff0c\u5982\u679c\u8d85\u8fc7\u4e00\u5b9a\u65f6\u95f4\u8fd8\u672a\u83b7\u53d6\u5230\u6240\u9700\u7684\u9501\uff0c\u5c31\u653e\u5f03\u5f53\u524d\u7684\u8d44\u6e90\u5e76\u91ca\u653e\u5df2\u7ecf\u6301\u6709\u7684\u8d44\u6e90\uff0c\u7136\u540e\u7b49\u5f85\u4e00\u6bb5\u65f6\u95f4\u518d\u91cd\u65b0\u5c1d\u8bd5\u3002\u8fd9\u53ef\u4ee5\u9632\u6b62\u7ebf\u7a0b\u957f\u65f6\u95f4\u7b49\u5f85\u800c\u5bfc\u81f4\u7684\u6b7b\u9501\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"15\"><strong><span style=\"font-size: 15px;\">\u4f7f\u7528tryLock()\u65b9\u6cd5<\/span><\/strong><span style=\"font-size: 15px;\">\uff1aReentrantLock\u7c7b\u63d0\u4f9b\u4e86tryLock()\u65b9\u6cd5\uff0c\u5b83\u53ef\u4ee5\u5728\u5c1d\u8bd5\u83b7\u53d6\u9501\u65f6\u8bbe\u5b9a\u4e00\u4e2a\u8d85\u65f6\u65f6\u95f4\uff0c\u5982\u679c\u5728\u89c4\u5b9a\u65f6\u95f4\u5185\u672a\u80fd\u83b7\u53d6\u9501\uff0c\u5219\u8fd4\u56defalse\uff0c\u53ef\u4ee5\u6839\u636e\u8fd4\u56de\u503c\u8fdb\u884c\u76f8\u5e94\u7684\u5904\u7406\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"17\"><strong><span style=\"font-size: 15px;\">\u8d44\u6e90\u5206\u914d\u56fe<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u4f7f\u7528\u8d44\u6e90\u5206\u914d\u56fe\u6765\u68c0\u6d4b\u6f5c\u5728\u7684\u6b7b\u9501\u60c5\u51b5\uff0c\u5e76\u6839\u636e\u8d44\u6e90\u5206\u914d\u56fe\u6765\u4f18\u5316\u8d44\u6e90\u7684\u5206\u914d\u548c\u8c03\u5ea6\uff0c\u4ece\u800c\u907f\u514d\u6b7b\u9501\u7684\u53d1\u751f\u3002<\/span><\/p>\n<\/li>\n<li>\n<p data-v-md-line=\"19\"><strong><span style=\"font-size: 15px;\">\u4f18\u5316\u8d44\u6e90\u7ba1\u7406<\/span><\/strong><span style=\"font-size: 15px;\">\uff1a\u5bf9\u4e8e\u4e00\u4e9b\u5fc5\u987b\u4e32\u884c\u8bbf\u95ee\u7684\u8d44\u6e90\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u5355\u4f8b\u6a21\u5f0f\u6216\u8005\u8fde\u63a5\u6c60\u7b49\u673a\u5236\uff0c\u51cf\u5c11\u8d44\u6e90\u7684\u7ade\u4e89\u548c\u51b2\u7a81\uff0c\u4ece\u800c\u964d\u4f4e\u6b7b\u9501\u7684\u98ce\u9669\u3002<\/span><\/p>\n<\/li>\n<\/ol>\n<p data-v-md-line=\"21\"><span style=\"font-size: 15px;\">\u603b\u4e4b\uff0c\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u9700\u8981\u7efc\u5408\u8003\u8651\u591a\u65b9\u9762\u56e0\u7d20\u6765\u89e3\u51b3\u6b7b\u9501\u95ee\u9898\uff0c\u5305\u62ec\u7cfb\u7edf\u7684\u8bbe\u8ba1\u67b6\u6784\u3001\u8d44\u6e90\u7684\u7ba1\u7406\u7b56\u7565\u3001\u7ebf\u7a0b\u7684\u8c03\u5ea6\u65b9\u5f0f\u7b49\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u9884\u9632\u548c\u89e3\u51b3\u6b7b\u9501\u95ee\u9898\u3002<\/span><\/p>\n<\/ol>\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:                 \u4e92\u8054\u7f51\u9762\u8bd5\u5c0f\u5e2e\u624b              <\/p>\n<\/blockquote>\n<\/div>\n","raw":"","protected":false},"excerpt":{"rendered":"<p>\u4ec0\u4e48\u662fJava\u6b7b\u9501\uff1f \u5728Java\u4e2d\uff0c\u6b7b\u9501\u662f\u6307\u4e24\u4e2a\u6216\u591a\u4e2a\u7ebf\u7a0b\u4e92\u76f8\u6301\u6709\u5bf9\u65b9\u6240\u9700\u7684\u8d44\u6e90\uff0c\u5e76\u56e0\u6b64\u5904\u4e8e\u6c38\u4e45\u963b\u585e\u7684\u72b6\u6001\u3002\u8fd9\u79cd\u60c5\u51b5\u53d1\u751f\u5728\u6bcf\u4e2a\u7ebf\u7a0b &#8230;<\/p>\n","protected":false},"author":1,"featured_media":4089,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"emotion":"","emotion_color":"","title_style":"","license":"","footnotes":""},"categories":[30],"tags":[],"class_list":["post-4092","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-30"],"post_thumbnail_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524145102427-150x150.jpeg","content_first_image":null,"post_medium_image_300":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524145102427-300x128.jpeg","post_thumbnail_image_624":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524145102427-1024x436.jpeg","post_frist_image":null,"post_medium_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524145102427-300x128.jpeg","post_large_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524145102427-1024x436.jpeg","post_full_image":"https:\/\/wp-moto-1258805347.cos.ap-shanghai.myqcloud.com\/2024\/05\/20240524145102427.jpeg","post_all_images":[],"videoAdId":"","listAd":"0","listAdId":"","listAdEvery":6,"total_comments":0,"category_name":"\u9762\u8bd5","post_date":"2024-04-21","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":276,"next_post_id":4552,"next_post_title":"\u9762\u8bd5\u5b98\uff1aRedis\u5982\u4f55\u4fdd\u969c\u9ad8\u53ef\u7528\u7684\uff1fRedis\u4e3b\u4ece\u3001\u54e8\u5175\u3001Redis Cluster\u4f60\u5206\u6e05\u695a\u4e86\u5417\uff1f","previous_post_id":4544,"previous_post_title":"\u9762\u8bd5\u5b98\uff1aRedis\u6709\u54ea\u4e9b\u6301\u4e45\u5316\u673a\u5236\uff08\u5982\u4f55\u4fdd\u969c\u6570\u636e\u4e0d\u4e22\u5931\uff09\uff1f\u8fd9\u4e2aRedis\u5fc5\u7b54\u9898\u4f60\u4e00\u5b9a\u4e0d\u8981\u9519\u8fc7\uff01","_links":{"self":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4092","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=4092"}],"version-history":[{"count":0,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/posts\/4092\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media\/4089"}],"wp:attachment":[{"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/media?parent=4092"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/categories?post=4092"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xinchewhd.com.cn\/index.php\/wp-json\/wp\/v2\/tags?post=4092"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}