{"id":65098,"date":"2025-05-03T11:08:09","date_gmt":"2025-05-03T03:08:09","guid":{"rendered":"https:\/\/fwq.ai\/blog\/65098\/"},"modified":"2025-05-03T11:08:09","modified_gmt":"2025-05-03T03:08:09","slug":"%e4%b8%ba%e4%bb%80%e4%b9%88%e4%bb%a3%e7%a0%81%e4%b8%ad%e5%8f%aa%e6%9c%89%e4%b8%80%e6%9d%a1%e7%ba%bf%e7%a8%8b%e5%9c%a8%e6%89%a7%e8%a1%8c%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/65098\/","title":{"rendered":"\u4e3a\u4ec0\u4e48\u4ee3\u7801\u4e2d\u53ea\u6709\u4e00\u6761\u7ebf\u7a0b\u5728\u6267\u884c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173112879223893.jpg\" class=\"aligncenter\" title=\"\u4e3a\u4ec0\u4e48\u4ee3\u7801\u4e2d\u53ea\u6709\u4e00\u6761\u7ebf\u7a0b\u5728\u6267\u884c\uff1f\u63d2\u56fe\" alt=\"\u4e3a\u4ec0\u4e48\u4ee3\u7801\u4e2d\u53ea\u6709\u4e00\u6761\u7ebf\u7a0b\u5728\u6267\u884c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6b64\u7a0b\u5e8f\u7684\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c\u80cc\u540e\u7684\u539f\u56e0<\/strong><\/p>\n<p>\u7ed9\u5b9a\u4ee3\u7801\u4e2d\uff0c\u5b58\u5728\u4e00\u4e2a\u5e38\u89c1\u7684\u7f16\u7a0b\u9519\u8bef\uff0c\u5bfc\u81f4\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u6b63\u5728\u6267\u884c\uff1a<\/p>\n<pre>if (this.flag = false) <\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u91cc\uff0c\u9519\u8bef\u5728\u4e8e\u5c06\u8d4b\u503c\u8fd0\u7b97\u7b26 = \u4e0e\u6bd4\u8f83\u8fd0\u7b97\u7b26 == \u6df7\u6dc6\u3002\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c= \u5e94\u8be5\u66ff\u6362\u4e3a ==\uff0c\u8868\u793a\u6bd4\u8f83\u64cd\u4f5c\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>if (this.flag == false) <\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u4fee\u6b63\u540e\u7684\u4ee3\u7801\u4e2d\uff0c\u7ebf\u7a0b\u5c06\u6309\u7167\u9884\u671f\u6b63\u5e38\u6267\u884c\u3002\u539f\u56e0\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li>flag \u662f\u4e00\u4e2a\u5e03\u5c14\u53d8\u91cf\uff0c\u7528\u6765\u6307\u793a\u8981\u6267\u884c\u54ea\u4e2a\u64cd\u4f5c\uff08\u52a0\u6cd5\u6216\u51cf\u6cd5\uff09\u3002<\/li>\n<li>\u5982\u679c flag \u4e3a true\uff0c\u5219\u6267\u884c\u52a0\u6cd5\u64cd\u4f5c\uff0c\u5426\u5219\u6267\u884c\u51cf\u6cd5\u64cd\u4f5c\u3002<\/li>\n<li>add() \u548c sub() \u65b9\u6cd5\u88ab\u58f0\u660e\u4e3a synchronized\uff0c\u8fd9\u610f\u5473\u7740\u4e00\u6b21\u53ea\u80fd\u6709\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c\u5b83\u4eec\u3002<\/li>\n<li>\u5728 add() \u65b9\u6cd5\u4e2d\uff0c\u5982\u679c\u6709\u7ebf\u7a0b\u8981\u51cf\u6cd5\uff0c\u5b83\u5c06\u8c03\u7528 wt()\uff0c\u91ca\u653e\u9501\u5e76\u7b49\u5f85 notifyall() \u88ab\u8c03\u7528\uff0c\u6b64\u65f6\u5b83\u4f1a\u7ee7\u7eed\u6267\u884c\u51cf\u6cd5\u64cd\u4f5c\u3002<\/li>\n<li>\u7c7b\u4f3c\u5730\uff0c\u5728 sub() \u65b9\u6cd5\u4e2d\uff0c\u5982\u679c\u6709\u7ebf\u7a0b\u8981\u52a0\u6cd5\uff0c\u5b83\u5c06\u8c03\u7528 wait()\uff0c\u91ca\u653e\u9501\u5e76\u7b49\u5f85 notifyall() \u88ab\u8c03\u7528\uff0c\u6b64\u65f6\u5b83\u4f1a\u7ee7\u7eed\u6267\u884c\u52a0\u6cd5\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p>\u56e0\u6b64\uff0c\u7531\u4e8e\u7f16\u7a0b\u9519\u8bef\u5bfc\u81f4\u5c06\u8d4b\u503c\u8fd0\u7b97\u7b26\u4e0e\u6bd4\u8f83\u8fd0\u7b97\u7b26\u6df7\u6dc6\uff0c\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u80fd\u591f\u6267\u884c\u3002\u5728\u4fee\u590d\u4ee3\u7801\u540e\uff0c\u7ebf\u7a0b\u5c06\u6b63\u5e38\u6267\u884c\uff0c\u5b9e\u73b0\u9884\u671f\u7684\u4ea4\u66ff\u52a0\u51cf\u64cd\u4f5c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u4ee3\u7801\u4e2d\u53ea\u6709\u4e00\u6761\u7ebf\u7a0b\u5728\u6267\u884c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6b64\u7a0b\u5e8f\u7684\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c\u80cc\u540e\u7684\u539f\u56e0 \u7ed9\u5b9a\u4ee3\u7801\u4e2d\uff0c\u5b58\u5728\u4e00\u4e2a\u5e38\u89c1\u7684\u7f16\u7a0b\u9519\u8bef\uff0c\u5bfc\u81f4\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u6b63\u5728\u6267\u884c\uff1a if (this.flag = false) \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u91cc\uff0c\u9519\u8bef\u5728\u4e8e\u5c06\u8d4b\u503c\u8fd0\u7b97\u7b26 = \u4e0e\u6bd4\u8f83\u8fd0\u7b97\u7b26 == \u6df7\u6dc6\u3002\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c= \u5e94\u8be5\u66ff\u6362\u4e3a ==\uff0c\u8868\u793a\u6bd4\u8f83\u64cd\u4f5c\uff0c\u5982\u4e0b\u6240\u793a\uff1a if (this.flag == false) \u767b\u5f55\u540e\u590d\u5236 \u5728\u4fee\u6b63\u540e\u7684\u4ee3\u7801\u4e2d\uff0c\u7ebf\u7a0b\u5c06\u6309\u7167\u9884\u671f\u6b63\u5e38\u6267\u884c\u3002\u539f\u56e0\u5982\u4e0b\uff1a flag \u662f\u4e00\u4e2a\u5e03\u5c14\u53d8\u91cf\uff0c\u7528\u6765\u6307\u793a\u8981\u6267\u884c\u54ea\u4e2a\u64cd\u4f5c\uff08\u52a0\u6cd5\u6216\u51cf\u6cd5\uff09\u3002 \u5982\u679c flag \u4e3a true\uff0c\u5219\u6267\u884c\u52a0\u6cd5\u64cd\u4f5c\uff0c\u5426\u5219\u6267\u884c\u51cf\u6cd5\u64cd\u4f5c\u3002 add() \u548c sub() \u65b9\u6cd5\u88ab\u58f0\u660e\u4e3a synchronized\uff0c\u8fd9\u610f\u5473\u7740\u4e00\u6b21\u53ea\u80fd\u6709\u4e00\u4e2a\u7ebf\u7a0b\u6267\u884c\u5b83\u4eec\u3002 \u5728 add() \u65b9\u6cd5\u4e2d\uff0c\u5982\u679c\u6709\u7ebf\u7a0b\u8981\u51cf\u6cd5\uff0c\u5b83\u5c06\u8c03\u7528 wt()\uff0c\u91ca\u653e\u9501\u5e76\u7b49\u5f85 notifyall() \u88ab\u8c03\u7528\uff0c\u6b64\u65f6\u5b83\u4f1a\u7ee7\u7eed\u6267\u884c\u51cf\u6cd5\u64cd\u4f5c\u3002 \u7c7b\u4f3c\u5730\uff0c\u5728 sub() \u65b9\u6cd5\u4e2d\uff0c\u5982\u679c\u6709\u7ebf\u7a0b\u8981\u52a0\u6cd5\uff0c\u5b83\u5c06\u8c03\u7528 wait()\uff0c\u91ca\u653e\u9501\u5e76\u7b49\u5f85 notifyall() \u88ab\u8c03\u7528\uff0c\u6b64\u65f6\u5b83\u4f1a\u7ee7\u7eed\u6267\u884c\u52a0\u6cd5\u64cd\u4f5c\u3002 \u56e0\u6b64\uff0c\u7531\u4e8e\u7f16\u7a0b\u9519\u8bef\u5bfc\u81f4\u5c06\u8d4b\u503c\u8fd0\u7b97\u7b26\u4e0e\u6bd4\u8f83\u8fd0\u7b97\u7b26\u6df7\u6dc6\uff0c\u53ea\u6709\u4e00\u4e2a\u7ebf\u7a0b\u80fd\u591f\u6267\u884c\u3002\u5728\u4fee\u590d\u4ee3\u7801\u540e\uff0c\u7ebf\u7a0b\u5c06\u6b63\u5e38\u6267\u884c\uff0c\u5b9e\u73b0\u9884\u671f\u7684\u4ea4\u66ff\u52a0\u51cf\u64cd\u4f5c\u3002 \u4ee5\u4e0a\u5c31\u662f\u4ee3\u7801\u4e2d\u53ea\u6709\u4e00\u6761\u7ebf\u7a0b\u5728\u6267\u884c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-65098","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65098","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=65098"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/65098\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=65098"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=65098"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=65098"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}