{"id":91451,"date":"2020-05-03T22:19:30","date_gmt":"2020-05-03T14:19:30","guid":{"rendered":"http:\/\/4563.org\/?p=91451"},"modified":"2020-05-03T22:19:30","modified_gmt":"2020-05-03T14:19:30","slug":"%e9%97%ae%e4%b8%8b%e5%85%b3%e4%ba%8e-java-synchronized-%e5%85%b3%e9%94%ae%e5%ad%97%e7%9a%84%e5%90%ab%e4%b9%89","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=91451","title":{"rendered":"\u95ee\u4e0b\u5173\u4e8e Java synchronized \u5173\u952e\u5b57\u7684\u542b\u4e49"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u95ee\u4e0b\u5173\u4e8e Java synchronized \u5173\u952e\u5b57\u7684\u542b\u4e49               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <span><i><\/i> 20<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6211\u76ee\u524d\u7406\u89e3\u7684\u662f synchronized \u4fee\u9970\u4ee3\u7801\u5757\u7684\u8bdd\uff0c\u5c31\u662f\u4fdd\u8bc1\u540c\u4e00\u65f6\u523b\u53ea\u80fd\u6709\u4e00\u4e2a\u7ebf\u7a0b\u8bbf\u95ee\u8fd9\u6bb5\u4ee3\u7801\uff0csynchronized(this)\u5c31\u76f8\u5f53\u4e8e\u8fd9\u4e2a\u7ebf\u7a0b\u83b7\u5f97\u4e86\u8fd9\u4e2a\u5bf9\u8c61\u5b9e\u4f8b\u7684\u9501\uff0c\u90a3\u50cf Object obj&#8230; synchronized(obj)\u8fd9\u79cd\u8981\u600e\u4e48\u7406\u89e3\u4e86\uff0c\u8fd8\u6709\u751f\u4ea7\u8005\u6d88\u8d39\u8005\u6a21\u578b\u4e2d\uff0c\u6211\u770b\u6709\u7684\u4ee3\u7801\u662f synchronized(queue)\uff0c\u90a3\u8fd9\u6837\u4e3a\u4ec0\u4e48\u53ef\u4ee5\u540c\u6b65\u5462\uff0c\u9501\u8fd9\u4e2a queu \u662f\u5e72\u4ec0\u4e48\u7528\u7684\uff0c\u662f\u5426\u6709\u66f4\u597d\u7684\u7406\u89e3\u3002<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"1249057\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : shiji <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/stackoverflow.com\/questions\/3047564\/java-synchronized-method-lock-on-object-or-method                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1249058\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : egglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9501\u5bf9\u8c61\u548c\u9501\u7c7b\uff0c\u767e\u5ea6\u4e0b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1249059\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @egglin \u767e\u5ea6\u6ca1\u80fd\u56de\u7b54\u6211\u7684\u95ee\u9898 orz \u6211\u4e0d\u7406\u89e3\u4e3a\u4ec0\u4e48\u968f\u4fbf\u5b9a\u4e49\u4e00\u4e2a\u5bf9\u8c61\u4e5f\u53ef\u4ee5\u4f5c\u4e3a synchronized \u9501\u7684\u5bf9\u8c61                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1249060\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : egglin <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @zxCoder \u7c7b\u4f3c redis \u5206\u5e03\u5f0f\u9501\uff0c\u603b\u8981\u627e\u4e2a key \u6765\u9501\u4e00\u4e0b\u561b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"1249061\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : zxCoder <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @egglin \u539f\u6765\u5c31\u8fd9\u4e48\u7b80\u5355\u7684\u5417&#8230;..\u61c2\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u4e0b\u5173\u4e8e Java synchro&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/91451"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=91451"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/91451\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=91451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=91451"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=91451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}