{"id":10008326,"date":"2023-09-25T19:54:52","date_gmt":"2023-09-25T11:54:52","guid":{"rendered":"https:\/\/blog.itmax.cn\/?p=10008326"},"modified":"2023-09-25T19:54:52","modified_gmt":"2023-09-25T11:54:52","slug":"12%e5%bc%a0%e5%9b%be%e4%b8%80%e6%ac%a1%e6%80%a7%e6%90%9e%e6%87%82%e9%ab%98%e6%80%a7%e8%83%bd%e5%b9%b6%e5%8f%91%e5%ae%b9%e5%99%a8concurrentlinkedqueue","status":"publish","type":"post","link":"https:\/\/itmax.cn\/?p=10008326","title":{"rendered":"12\u5f20\u56fe\u4e00\u6b21\u6027\u641e\u61c2\u9ad8\u6027\u80fd\u5e76\u53d1\u5bb9\u5668ConcurrentLinkedQueue"},"content":{"rendered":"<h3>12\u5f20\u56fe\u4e00\u6b21\u6027\u641e\u61c2\u9ad8\u6027\u80fd\u5e76\u53d1\u5bb9\u5668ConcurrentLinkedQueue<\/h3>\n<h3>\u524d\u8a00<\/h3>\n<p>\u4e0a\u7bc7\u6587\u7ae0\u804a\u5230\u5e76\u53d1\u96c6\u5408<code>CopyOnWeiteArrayList<\/code>\u7684\u5b9e\u73b0\u4e0e\u7279\u70b9\uff0c\u5176\u4e0d\u8db3\u4e4b\u5904\u662f\u4e0d\u9002\u5408\u5199\u591a\u7684\u573a\u666f\u4e5f\u4e0d\u9002\u5408\u5e76\u53d1\u91cf\u5927\u7684\u573a\u666f<\/p>\n<p>\u672c\u7bc7\u6587\u7ae0\u6765\u804a\u804a\u5e76\u53d1\u573a\u666f\u4e0b\u9ad8\u6027\u80fd\u7684<code>ConcurrentLinkedQueue<\/code><\/p>\n<p>\u9605\u8bfb\u672c\u6587\u5927\u6982\u9700\u898110\u5206\u949f<\/p>\n<p>\u5728\u9605\u8bfb\u672c\u6587\u524d\uff0c\u9700\u8981\u7406\u89e3CAS\u3001volatile\u7b49\u77e5\u8bc6<\/p>\n<p>\u5982\u679c\u4e0d\u7406\u89e3CAS\u53ef\u4ee5\u67e5\u770b\u8fd9\u7bc7\u6587\u7ae0<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=JIagpQzFoVFAZN62%2BHf1YA%3D%3D.9q5Uugn8Xoml4jbLNid2hZ06vvn5YP2iSC4kIsjX%2FMmz2VsJKUDcoU5m5PwAleXJ%2BGOBqrFeNSSKSN4FGrWsCw%3D%3D\" rel=\"noopener noreferrer\">15000\u5b57\u30016\u4e2a\u4ee3\u7801\u6848\u4f8b\u30015\u4e2a\u539f\u7406\u56fe\u8ba9\u4f60\u5f7b\u5e95\u641e\u61c2Synchronized <\/a>\u7684\u7b2c\u4e8c\u5c0f\u8282<\/p>\n<p>\u5982\u679c\u4e0d\u7406\u89e3volatile\u53ef\u4ee5\u67e5\u770b\u8fd9\u7bc7\u6587\u7ae0<a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=un0JNnTAKqNdYCOSSGrHdQ%3D%3D.mNxkWBFJHIzc7624t3FIyW4nHCKLnjgd5xukEc4mPTDXoaLRyGg8L1mX5GKnzl4q\" rel=\"noopener noreferrer\">5\u4e2a\u6848\u4f8b\u548c\u6d41\u7a0b\u56fe\u8ba9\u4f60\u4ece0\u52301\u641e\u61c2volatile\u5173\u952e\u5b57<\/a><\/p>\n<h3>\u6570\u636e\u7ed3\u6784<\/h3>\n<p><code>ConcurrentLinkedQueue<\/code>\u4ece\u540d\u79f0\u4e0a\u6765\u770b\u5c31\u80fd\u591f\u77e5\u9053\uff0c\u5b83\u652f\u6301\u5e76\u53d1\u3001\u7531\u94fe\u8868\u5b9e\u73b0\u7684\u961f\u5217<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"675\" height=\"497\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVc\" alt=\"image.png\" title=\"image.png\"><\/p>\n<p>\u901a\u8fc7\u6e90\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230<strong><code>ConcurrentLinkedQueue<\/code>\u4f7f\u7528\u5b57\u6bb5\u8bb0\u5f55\u9996\u5c3e\u8282\u70b9\u3001\u5e76\u4e14\u8282\u70b9\u7684\u5b9e\u73b0\u662f\u5355\u5411\u94fe\u8868<\/strong><\/p>\n<p>\u5e76\u4e14\u8fd9\u4e9b\u5173\u952e\u5b57\u6bb5\u90fd\u88abvolatile\u4fee\u9970\uff0c<strong>\u5728\u8bfb\u573a\u666f\u4e0b\u4f7f\u7528volatile\u4fdd\u8bc1\u53ef\u89c1\u6027\uff0c\u4e0d\u7528\u201c\u52a0\u9501\u201d<\/strong><\/p>\n<p>\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u5b57\u6bb5\uff0c\u6bd4\u5982\u4f7f\u7528CAS\u7684Unsafe\u548c\u4e00\u4e9b\u504f\u79fb\u91cf\u4fe1\u606f\u7b49\uff0c\u8fd9\u91cc\u5c31\u4e0d\u4e00\u4e00\u5217\u4e3e<\/p>\n<pre><code class=\"java\">  public class ConcurrentLinkedQueue&lt;E&gt; extends AbstractQueue&lt;E&gt;\n          implements Queue&lt;E&gt;, java.io.Serializable {    \n  \n      private static class Node&lt;E&gt; {\n          \/\/\u8bb0\u5f55\u6570\u636e\n          volatile E item;\n          \/\/\u540e\u7ee7\u8282\u70b9\n          volatile Node&lt;E&gt; next;\n      }\n      \/\/\u9996\u8282\u70b9\n      private transient volatile Node&lt;E&gt; head;\n      \/\/\u5c3e\u8282\u70b9\n      private transient volatile Node&lt;E&gt; tail;\n  }   <\/code><\/pre>\n<p>\u5728\u521d\u59cb\u5316\u65f6\uff0c\u9996\u5c3e\u8282\u70b9\u4f1a\u540c\u65f6\u6307\u5411\u4e00\u4e2a\u5b58\u50a8\u6570\u636e\u4e3a\u7a7a\u7684\u8282\u70b9<\/p>\n<pre><code class=\"java\">      public ConcurrentLinkedQueue() {\n          head = tail = new Node&lt;E&gt;(null);\n      }<\/code><\/pre>\n<h3>\u8bbe\u8ba1\u601d\u60f3<\/h3>\n<h4>\u5ef6\u8fdf\u66f4\u65b0\u9996\u5c3e\u8282\u70b9<\/h4>\n<p>\u5728\u67e5\u770b\u5b9e\u73b0\u539f\u7406\u524d\uff0c\u6211\u4eec\u5148\u6765\u8bf4\u8bf4<code>ConcurrentLinkedQueue<\/code>\u7684\u8bbe\u8ba1\u601d\u60f3\uff0c\u5426\u5219\u5b9e\u73b0\u539f\u7406\u53ef\u80fd\u4f1a\u770b\u4e0d\u61c2<\/p>\n<p><strong><code>ConcurrentLinkedQueue<\/code>\u5199\u573a\u666f\u4e2d\u91c7\u7528\u4e50\u89c2\u9501\u7684\u601d\u60f3\uff0c\u4f7f\u7528CAS+\u5931\u8d25\u91cd\u8bd5\u6765\u4fdd\u8bc1\u64cd\u4f5c\u7684\u539f\u5b50\u6027<\/strong><\/p>\n<p>\u4e3a\u4e86\u907f\u514dCAS\u5f00\u9500\u8fc7\u5927\uff0c<strong><code>ConcurrentLinkedQueue<\/code>\u91c7\u7528\u5ef6\u8fdf\u66f4\u65b0\u9996\u5c3e\u8282\u70b9\u7684\u601d\u60f3\uff0c\u6765\u51cf\u5c11CAS\u6b21\u6570<\/strong><\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4<code>ConcurrentLinkedQueue<\/code>\u4e2d\u7684\u9996\u5c3e\u8282\u70b9\u5e76\u4e0d\u4e00\u5b9a\u662f\u6700\u65b0\u7684\u9996\u5c3e\u8282\u70b9<\/p>\n<h4>\u54e8\u5175\u8282\u70b9<\/h4>\n<p><code>ConcurrentLinkedQueue<\/code>\u7684\u8bbe\u8ba1\u4e2d\u4f7f\u7528\u54e8\u5175\u8282\u70b9<\/p>\n<p>\u4ec0\u4e48\u662f\u54e8\u5175\u8282\u70b9\uff1f<\/p>\n<p>\u54e8\u5175\u8282\u70b9\u53c8\u79f0\u865a\u62df\u8282\u70b9\uff0c\u54e8\u5175\u8282\u70b9\u5e38\u4f7f\u7528\u5728\u94fe\u8868\u8fd9\u79cd\u6570\u636e\u7ed3\u6784\u4e2d<\/p>\n<p>\u5355\u5411\u94fe\u8868\u4e2d\u5982\u679c\u8981\u6dfb\u52a0\u6216\u8005\u5220\u9664\u67d0\u4e2a\u8282\u70b9\u65f6\uff0c\u4e00\u5b9a\u8981\u83b7\u5f97\u8fd9\u4e2a\u8282\u70b9\u7684\u524d\u9a71\u8282\u70b9\u518d\u53bb\u8fdb\u884c\u64cd\u4f5c<\/p>\n<p>\u5f53\u64cd\u4f5c\u7684\u662f\u7b2c\u4e00\u4e2a\u8282\u70b9\u65f6\uff0c\u5982\u679c\u5728\u7b2c\u4e00\u4e2a\u8282\u70b9\u524d\u9762\u52a0\u4e2a\u865a\u62df\u8282\u70b9\uff08\u54e8\u5175\u8282\u70b9\uff09\uff0c\u90a3\u4e48\u5c31\u4e0d\u7528\u7279\u6b8a\u5904\u7406<\/p>\n<p>\u6362\u800c\u8a00\u4e4b<strong>\u4f7f\u7528\u54e8\u5175\u8282\u70b9\u53ef\u4ee5\u51cf\u5c11\u4ee3\u7801\u590d\u6742\u5ea6<\/strong>\uff0c\u76f8\u4fe1\u5237\u8fc7\u94fe\u8868\u76f8\u5173\u7b97\u6cd5\u7684\u540c\u5b66\u6df1\u6709\u4f53\u4f1a<\/p>\n<p>\u54e8\u5175\u8282\u70b9\u8fd8\u80fd\u591f\u5728\u53ea\u6709\u4e00\u4e2a\u8282\u70b9\u65f6\u51cf\u5c11\u5e76\u53d1\u51b2\u7a81<\/p>\n<p>\u8fd9\u4e00\u7279\u70b9\u53ef\u80fd\u8981\u770b\u5b8c\u540e\u7eed\u5b9e\u73b0\u548c\u6d41\u7a0b\u56fe\u624d\u80fd\u7406\u89e3<\/p>\n<h3>\u6e90\u7801\u5b9e\u73b0<\/h3>\n<p><code>ConcurrentLinkedQueue<\/code>\u4e3b\u8981\u7684\u64cd\u4f5c\u662f\u5165\u961f\u3001\u51fa\u961f\uff0c\u6211\u4eec\u4f7f\u7528<code>offer<\/code>\u548c<code>poll<\/code>\u6765\u5bf9\u5176\u8fdb\u884c\u5206\u6790<\/p>\n<h4>offer<\/h4>\n<p>\u5728\u5206\u6790\u6e90\u7801\u524d\uff0c\u5148\u6765\u8bf4\u660e\u4e00\u4e9b\u590d\u6742\u53d8\u91cf\u7684\u4f5c\u7528<\/p>\n<p><strong>t\u8bb0\u5f55\u5c3e\u8282\u70b9tail<\/strong><\/p>\n<p><strong>p\u7528\u4e8e\u5faa\u73af\u904d\u5386\u7684\u8282\u70b9\uff0c\u5f53p\u8282\u70b9\u4e3a\u771f\u6b63\u5c3e\u8282\u70b9\u65f6\u624d\u5141\u8bb8\u6dfb\u52a0\u65b0\u8282\u70b9<\/strong><\/p>\n<p><strong>q \u7528\u4e8e\u8bb0\u5f55p\u7684\u540e\u7ee7\u8282\u70b9<\/strong><\/p>\n<p>\u5728\u5165\u961f\u65f6\u5206\u4e09\u79cd\u60c5\u51b5\uff1a<\/p>\n<ol>\n<li><strong>\u5f53p\u7684\u540e\u7ee7\u8282\u70b9\u4e3a\u7a7a\u65f6\uff08p\u4e3a\u771f\u6b63\u5c3e\u8282\u70b9\uff09\uff0c\u5c1d\u8bd5CAS\u589e\u52a0\u65b0\u8282\u70b9\uff0c\u6210\u529f\u540e\u5c1d\u8bd5\u66f4\u65b0\u5c3e\u8282\u70b9tail<\/strong><\/li>\n<li><strong>\u5f53p\u7b49\u4e8ep\u7684\u540e\u7ee7\u8282\u70b9\u65f6\uff08p\u7684next\u6307\u5411\u81ea\u5df1\uff0c\u8bf4\u660e\u6784\u5efa\u6210\u54e8\u5175\u8282\u70b9\uff0c\u51fa\u961fpoll\u65f6\u53ef\u80fd\u6784\u9020\u54e8\u5175\u8282\u70b9\uff09\uff1b\u6b64\u65f6\u5224\u65ad\u5c3e\u8282\u70b9\u662f\u5426\u88ab\u4fee\u6539\u8fc7\uff0c\u5982\u679c\u5c3e\u8282\u70b9\u88ab\u4fee\u6539\u8fc7\u5c31\u5b9a\u4f4d\u5230\u5c3e\u8282\u70b9\uff0c\u5982\u679c\u672a\u88ab\u4fee\u6539\u8fc7\uff08\u4f7f\u7528next\u65e0\u6cd5\u7ee7\u7eed\u904d\u5386\uff09\uff0c\u53ea\u80fd\u5b9a\u4f4d\u5230\u5934\u8282\u70b9<\/strong><\/li>\n<li><strong>\u5176\u4ed6\u60c5\u51b5\u65f6\uff0c\u8bf4\u660e\u6b64\u65f6\u7684p\u5e76\u4e0d\u662f\u771f\u6b63\u7684\u5c3e\u8282\u70b9\uff0c\u9700\u8981\u5b9a\u4f4d\u5230\u771f\u6b63\u5c3e\u8282\u70b9\uff1b\u6b64\u65f6\u5982\u679cp\u4e0d\u662f\u539f\u6765\u7684\u5c3e\u8282\u70b9\u5e76\u4e14\u5c3e\u8282\u70b9\u88ab\u4fee\u6539\u8fc7\uff0c\u90a3\u5c31\u5b9a\u4f4d\u5230\u5c3e\u8282\u70b9\uff0c\u5426\u5219\u5b9a\u4f4d\u5230\u540e\u7ee7\u8282\u70b9\u7ee7\u7eed\u904d\u5386<\/strong><\/li>\n<\/ol>\n<p>\u7b2c\u4e8c\u3001\u4e09\u79cd\u60c5\u51b5\u7684\u4ee3\u7801\u89c2\u8d4f\u6027\u5f88\u597d\u4f46\u662f\u53ef\u8bfb\u6027\u4e0d\u597d\uff0c\u53ef\u4ee5\u5c06\u603b\u7ed3\u7684\u60c5\u51b5\u4e0e\u6e90\u7801\u5206\u6790\u4e00\u8d77\u89c2\u770b\uff0c\u5982\u679c\u8fd8\u662f\u4e0d\u7406\u89e3\u540e\u7eed\u6709\u6d41\u7a0b\u56fe\u65b9\u4fbf\u7406\u89e3<\/p>\n<pre><code class=\"java\">      public boolean offer(E e) {\n          \/\/\u68c0\u67e5\u7a7a\u6307\u9488\n          checkNotNull(e);\n          \/\/\u6784\u5efa\u65b0\u8282\u70b9\n          final Node&lt;E&gt; newNode = new Node&lt;E&gt;(e);\n          \/\/\u5931\u8d25\u91cd\u8bd5\u7684\u5faa\u73af\n          \/\/t:\u5f53\u524d\u8bb0\u5f55\u7684\u5c3e\u8282\u70b9\n          \/\/p:\u771f\u6b63\u7684\u5c3e\u8282\u70b9\n          \/\/q:p\u7684\u540e\u7ee7\u8282\u70b9\n          for (Node&lt;E&gt; t = tail, p = t;;) {\n              Node&lt;E&gt; q = p.next;\n              \/\/\u60c5\u51b51\uff1ap\u7684\u540e\u7ee7\u8282\u70b9\u4e3a\u7a7a\uff0c\u8bf4\u660e\u5f53\u524dp\u5c31\u662f\u771f\u6b63\u5c3e\u8282\u70b9\n              if (q == null) {\n                  \/\/\u5c1d\u8bd5CAS\u4fee\u6539p\u7684\u540e\u7ee7\u8282\u70b9\u4e3a\u65b0\u8282\u70b9\n                  \/\/\u5982\u679cp\u7684next\u662fnull \u5219\u66ff\u6362\u6210\u65b0\u8282\u70b9newNode\n                  \/\/\u5931\u8d25\u5219\u8bf4\u660e\u5176\u4ed6\u7ebf\u7a0bcas\u6dfb\u52a0\u8282\u70b9\u6210\u529f\uff0c\u7ee7\u7eed\u5faa\u73af\uff1b\u6210\u529f\u5219\u5224\u65ad\u662f\u5426\u66f4\u65b0\u5c3e\u8282\u70b9tail\n                  if (p.casNext(null, newNode)) {\n                      \/\/\u5982\u679cp\u4e0d\u7b49\u4e8et \u8bf4\u660e\u6b64\u65f6\u7684\u5c3e\u8282\u70b9\u4e0d\u662f\u771f\u6b63\u7684\u5c3e\u8282\u70b9\n                      \/\/\u5c1d\u8bd5CAS\uff1a\u5982\u679c\u5f53\u524d\u5c3e\u8282\u70b9\u662ft\uff0c\u90a3\u4e48\u5c31\u5c06\u65b0\u8282\u70b9\u8bbe\u7f6e\u6210\u5c3e\u8282\u70b9\n                      if (p != t) \n                          casTail(t, newNode);  \n                      return true;\n                  }\n                  \n              }\n              \/\/\u60c5\u51b52:p\u7b49\u4e8ep\u7684\u540e\u7ee7\u8282\u70b9\uff08p\u6307\u5411\u81ea\u5df1\uff09\n              else if (p == q)\n                  \/\/t\uff1a\u65e7\u7684\u5c3e\u8282\u70b9\n                  \/\/(t = tail)\uff1a\u65b0\u7684\u5c3e\u8282\u70b9\n                  \/\/t != (t = tail): \u8bf4\u660e\u5c3e\u8282\u70b9\u88ab\u4fee\u6539\u8fc7\uff0cp\u7b49\u4e8e\u65b0\u7684\u5c3e\u8282\u70b9\uff1b\u672a\u88ab\u4fee\u6539\u8fc7\uff0cp\u7b49\u4e8e\u5934\u8282\u70b9\n                  p = (t != (t = tail)) ? t : head;\n              \n              \/\/\u60c5\u51b53\uff1a\u6b64\u65f6p\u4e0d\u662f\u771f\u6b63\u5c3e\u8282\u70b9\uff0c\u9700\u8981\u53bb\u5b9a\u4f4d\u771f\u6b63\u5c3e\u8282\u70b9\n              else\n                  \/\/p!=t:p\u4e0d\u518d\u662f\u539f\u6765\u7684\u5c3e\u8282\u70b9\n                  \/\/t != (t = tail):\u5c3e\u8282\u70b9\u88ab\u4fee\u6539\u8fc7\n                  \/\/p\u4e0d\u518d\u662f\u539f\u6765\u7684\u5c3e\u8282\u70b9 \u5e76\u4e14 \u5c3e\u8282\u70b9\u88ab\u4fee\u6539\u8fc7 \u5c31\u8ba9p\u7b49\u4e8e\u4fee\u6539\u8fc7\u7684\u5c3e\u8282\u70b9\uff1b\u5426\u5219\u8ba9p\u7b49\u4e8e\u5b83\u7684\u540e\u7ee7\u8282\u70b9q\n                  p = (p != t &amp;&amp; t != (t = tail)) ? t : q;\n          }\n      }<\/code><\/pre>\n<h4>poll<\/h4>\n<p>\u5982\u679c\u7406\u89e3\u5165\u961foffer\u4e2d\u7684\u53d8\u91cf\uff0c\u90a3\u4e48\u51fa\u961fpoll\u4e5f\u597d\u7406\u89e3\uff0c\u5176\u4e2dp\u548cq\u90fd\u662f\u7c7b\u4f3c\u7684<\/p>\n<p><strong>h\u8bb0\u5f55\u5934\u8282\u70b9head<\/strong><\/p>\n<p><strong>p\u7528\u4e8e\u5faa\u73af\u904d\u5386\u7684\u8282\u70b9\uff0c\u5f53p\u8282\u70b9\u4e3a\u771f\u6b63\u5934\u8282\u70b9\u65f6\u624d\u5141\u8bb8\u51fa\u961f<\/strong><\/p>\n<p><strong>q \u7528\u4e8e\u8bb0\u5f55p\u7684\u540e\u7ee7\u8282\u70b9<\/strong><\/p>\n<p>\u51fa\u961f\u7684\u60c5\u51b5\u5206\u4e3a\u56db\u79cd<\/p>\n<ol>\n<li><strong>\u5f53p\u4e3a\u771f\u6b63\u5934\u8282\u70b9\u65f6\uff0cCAS\u5c06\u6570\u636e\u8bbe\u7f6e\u4e3a\u7a7a\uff0c\u7136\u540e\u5224\u65adhead\u662f\u5426\u4e3a\u771f\u6b63\u5934\u8282\u70b9\uff0c\u4e0d\u662f\u5219\u66f4\u65b0\u5934\u8282\u70b9\uff0c\u7136\u540e\u5c06\u539f\u6765\u7684\u5934\u8282\u70b9next\u6307\u5411\u5b83\u81ea\u5df1\u6784\u5efa\u6210\u54e8\u5175\u8282\u70b9<\/strong><\/li>\n<li><strong>\u5f53p\u7684\u540e\u7ee7\u8282\u70b9\u4e3a\u7a7a\u65f6\uff0c\u8bf4\u660e\u961f\u5217\u4e3a\u7a7a\uff0c\u5c1d\u8bd5CAS\u5c06\u5934\u8282\u70b9\u4fee\u6539\u6210p<\/strong><\/li>\n<li><strong>\u5982\u679cp\u7684\u540e\u7ee7\u8282\u70b9\u662f\u5b83\u81ea\u5df1\uff0c\u8bf4\u660e\u5176\u4ed6\u7ebf\u7a0bpoll\u51fa\u961f\u6784\u5efa\u6210\u54e8\u5175\u8282\u70b9\uff0c\u8df3\u8fc7\u672c\u6b21\u5faa\u73af<\/strong><\/li>\n<li><strong>\u5176\u4ed6\u60c5\u51b5\u5219\u5411\u540e\u904d\u5386<\/strong><\/li>\n<\/ol>\n<pre><code class=\"java\">     public E poll() {\n         \/\/\u65b9\u4fbf\u9000\u51fa\u53cc\u91cd\u5faa\u73af\n         restartFromHead:\n         for (;;) {\n             \/\/h\u8bb0\u5f55\u5934\u8282\u70b9\n             \/\/p\u771f\u6b63\u5934\u8282\u70b9\n             \/\/q\u4e3ap\u7684\u540e\u7ee7\u8282\u70b9\n             for (Node&lt;E&gt; h = head, p = h, q;;) {\n                 \/\/\u83b7\u53d6p\u8282\u70b9\u7684\u6570\u636e\n                 E item = p.item;\n                 \/\/\u60c5\u51b51\uff1a\n                 \/\/\u5982\u679c\u6570\u636e\u4e0d\u4e3a\u7a7a \u8bf4\u660ep\u8282\u70b9\u4e3a\u771f\u6b63\u5934\u8282\u70b9\n                 \/\/\u5c1d\u8bd5CAS\u5c06\u6570\u636e\u8bbe\u7f6e\u4e3anull,\u5982\u679c\u6570\u636e\u4e3aitem\u5219\u66ff\u6362\u4e3anull\uff0c\u5931\u8d25\u5219\u8bf4\u660e\u5176\u4ed6\u7ebf\u7a0b\u4ee5\u53ca\u51fa\u961f\uff0c\u7ee7\u7eed\u5faa\u73af\n                 if (item != null &amp;&amp; p.casItem(item, null)) {\n                     \/\/\u5982\u679c\u5f53\u524d\u5934\u8282\u70b9\u4e0d\u662f\u771f\u6b63\u5934\u8282\u70b9\u5219\u66f4\u65b0\u5934\u8282\u70b9\n                     if (p != h) \n                         updateHead(h, ((q = p.next) != null) ? q : p);\n                     return item;\n                 }\n                 \/\/\u60c5\u51b52\uff1a\n                 \/\/p\u7684\u540e\u7ee7\u8282\u70b9\u4e3a\u7a7a\uff0c\u8bf4\u660e\u5f53\u524d\u4e3a\u7a7a\u961f\u5217\uff0c\u5c1d\u8bd5CAS\u5c06\u5934\u8282\u70b9\u4fee\u6539\u4e3ap\uff08p\u6b64\u65f6\u53ef\u80fd\u662f\u54e8\u5175\u8282\u70b9\uff09\n                 else if ((q = p.next) == null) {\n                     updateHead(h, p);\n                     return null;\n                 }\n                 \/\/\u60c5\u51b53:\n                 \/\/\u5982\u679cp\u7684\u540e\u7ee7\u8282\u70b9\u6307\u5411p\u81ea\u5df1\uff0c\u8bf4\u660e\u5176\u4ed6\u7ebf\u7a0bpoll\u51fa\u961f\u65f6\u6784\u5efa\u6210\u54e8\u5175\u8282\u70b9\uff0c\u8df3\u8fc7\u672c\u6b21\u5faa\u73af\n                 else if (p == q)\n                     continue restartFromHead;\n                 \/\/\u60c5\u51b54:\n                 \/\/p\u5b9a\u4f4d\u4e3a\u540e\u7ee7\u8282\u70b9\u9700\u8981\u904d\u5386\n                 else\n                     p = q;\n             }\n         }\n     }<\/code><\/pre>\n<p>\u5728\u66f4\u65b0\u5934\u8282\u70b9\u65b9\u6cd5\u4e2d\uff0c\u4f1a\u8fdb\u884c\u5224\u65ad<\/p>\n<p><strong>\u5982\u679c\u5f53\u524d\u5934\u8282\u70b9\u4e0d\u662f\u771f\u6b63\u5934\u8282\u70b9\uff0c\u5219\u5c1d\u8bd5CAS\u5c06\u5934\u8282\u70b9\u8bbe\u7f6e\u6210p\u771f\u6b63\u5934\u8282\u70b9<\/strong><\/p>\n<p><strong>CAS\u6210\u529f\u540e\u5c06\u539f\u6765\u7684\u5934\u8282\u70b9\u7684next\u6307\u5411\u5b83\u81ea\u5df1\uff0c\u6784\u5efa\u6210\u54e8\u5175\u8282\u70b9<\/strong><\/p>\n<pre><code class=\"java\">final void updateHead(Node&lt;E&gt; h, Node&lt;E&gt; p) {\n    if (h != p &amp;&amp; casHead(h, p))\n        h.lazySetNext(h);\n}<\/code><\/pre>\n<h3>\u6d41\u7a0b\u56fe\u5b9e\u73b0<\/h3>\n<p>\u60f3\u8981\u8ddf\u7740debug\u7684\u540c\u5b66\uff0c\u9700\u8981\u628aidea\u4e2d\u7684\u8fd9\u4e24\u4e2a\u8bbe\u7f6e\u5173\u95ed\uff0c\u5426\u5219debug\u4f1a\u6709\u8bef<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"451\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVd\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u4e3a\u4e86\u66f4\u5bb9\u6613\u7684\u7406\u89e3\uff0c\u6211\u4eec\u6765\u770b\u4e00\u6bb5\u7b80\u5355\u7684\u4ee3\u7801\uff0c\u5e76\u9644\u5e26\u5176\u5b9e\u73b0\u6d41\u7a0b\u56fe<\/p>\n<pre><code class=\"java\">    public void testConcurrentLinkedQueue()  {\n        ConcurrentLinkedQueue&lt;String&gt; queue = new ConcurrentLinkedQueue&lt;&gt;();\n\n        queue.offer(&quot;h1&quot;);\n        queue.offer(&quot;h2&quot;);\n        queue.offer(&quot;h3&quot;);\n\n        String p1 = queue.poll();\n        String p2 = queue.poll();\n        String p3 = queue.poll();\n        String p4 = queue.poll();\n\n        queue.offer(&quot;h4&quot;);\n        System.out.println(queue);\n    }<\/code><\/pre>\n<p>\u3010\u58f0\u660e\uff1a\u5982\u679c\u56fe\u4e2d\u8282\u70b9item\u6ca1\u5199\u6570\u636e\uff0c\u8bf4\u660e\u5b58\u50a8\u7684\u6570\u636e\u4e3a\u7a7a\uff1b\u5982\u679c\u8282\u70b9next\u6ca1\u753b\u6307\u5411\u5173\u7cfb\uff0c\u4e5f\u8bf4\u660e\u4e3a\u7a7a\u3011<\/p>\n<p>\u6267\u884c\u6784\u9020\u65f6\uff0c\u4f1a\u521d\u59cb\u5316\u9996\u5c3e\u8282\u70b9\u6307\u5411\u540c\u4e00\u4e2a\u6570\u636e\u4e3a\u7a7a\u7684\u8282\u70b9<\/p>\n<p><img decoding=\"async\" width=\"676\" height=\"334\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVe\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5728\u7b2c\u4e00\u6b21\u5165\u961f\u65f6\uff0c\u4e00\u8fdb\u5165\u5faa\u73af\u5c31\u6ee1\u8db3\u7b2c\u4e00\u79cd\u60c5\u51b5\uff0c\u6b64\u65f6\u7684p\u5c31\u662f\u771f\u6b63\u5c3e\u8282\u70b9\uff0c\u76f4\u63a5CAS\u8bbe\u7f6enext\u4e3a\u65b0\u8282\u70b9\uff0c\u4f46\u7531\u4e8ep\u4e0etail\u76f8\u540c\uff0c\u5c31\u4e0d\u4f1a\u66f4\u65b0\u5c3e\u8282\u70b9tail<\/p>\n<p>\u56e0\u6b64\u9996\u5c3e\u8282\u70b9\u8fd8\u662f\u54e8\u5175\u8282\u70b9\uff0c\u800c\u54e8\u5175\u8282\u70b9\u7684next\u6307\u5411\u65b0\u5165\u961f\u7684\u8282\u70b9<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"270\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVg\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5728\u7b2c\u4e8c\u6b21\u5165\u961f\u65f6\uff0c\u7531\u4e8e\u6b64\u65f6\u7684p(tail)\u4e0d\u662f\u771f\u6b63\u5c3e\u8282\u70b9\uff0c\u4f1a\u6765\u5230\u7b2c\u4e09\u79cd\u60c5\u51b5\uff0c\u7531\u4e8etail\u6ca1\u88ab\u4fee\u6539\u8fc7\uff0cp\u4f1a\u88ab\u6539\u6210\u5b83\u7684\u540e\u7ee7\u8282\u70b9\uff0c\u7ee7\u7eed\u5411\u540e\u904d\u5386<\/p>\n<p>\u5728\u7b2c\u4e8c\u6b21\u5faa\u73af\u65f6\uff0cp\u5c31\u662f\u771f\u6b63\u5c3e\u8282\u70b9\uff0c\u4e8e\u662f\u5c1d\u8bd5CAS\u6dfb\u52a0\u65b0\u8282\u70b9\uff0c\u7531\u4e8e\u6b64\u65f6p\u548c\u5c3e\u8282\u70b9tail\u4e0d\u540c\uff0c\u4e8e\u662f\u4f1a\u66f4\u65b0tail<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"198\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVh\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5728\u7b2c\u4e09\u6b21\u5165\u961f\u65f6\uff0c\u60c5\u51b5\u4e0e\u7b2c\u4e00\u6b21\u5165\u961f\u76f8\u540c<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"173\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVj\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u6b64\u65f6\u961f\u5217\u4e2d\u5b58\u5728\u54e8\u5175\u8282\u70b9\u548ch1\u3001h2\u3001h3\u56db\u4e2a\u8282\u70b9<\/p>\n<p>\u5728\u7b2c\u4e00\u6b21\u51fa\u961f\u65f6\uff0c\u7531\u4e8ehead\u6307\u5411\u7684\u54e8\u5175\u8282\u70b9\u6570\u636e\u57df\u4e3a\u7a7a\uff0c\u4f1a\u6765\u5230\u7b2c\u56db\u79cd\u60c5\u51b5\uff0c\u5373\u5c06p\u6539\u4e3a\u5b83\u7684\u540e\u7ee7\u8282\u70b9\uff0c\u7ee7\u7eed\u5411\u540e\u904d\u5386<\/p>\n<p>\u5728\u7b2c\u4e8c\u6b21\u5faa\u73af\u65f6\uff0cp\u4e3ah1\u8282\u70b9\uff0c\u7531\u4e8e\u6570\u636e\u4e0d\u4e3a\u7a7a\uff0cCAS\u5c06\u6570\u636e\u8bbe\u7f6e\u4e3a\u7a7a<\/p>\n<p><code>p.casItem(item, null)<\/code> \u5c06\u539fh1\u8282\u70b9\u6570\u636e\u8bbe\u7f6e\u4e3a\u7a7a<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"145\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVk\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u6b64\u65f6head\u5e76\u4e0d\u662f\u771f\u6b63\u5934\u8282\u70b9\uff0c\u4e8e\u662f\u4f1a\u66f4\u65b0head<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"167\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVl\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u7136\u540e\u5c06\u539f\u6765\u7684head\u6307\u5411\u5b83\u81ea\u5df1\uff0c\u6784\u5efa\u6210\u54e8\u5175\u8282\u70b9\uff0c\u65b9\u4fbf\u4e2d\u95f4\u4e24\u4e2a\u4e0d\u518d\u4f7f\u7528\u7684\u8282\u70b9GC<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"158\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVm\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5728\u7b2c\u4e8c\u6b21\u51fa\u961f\u65f6\uff0c\u6ee1\u8db3\u7b2c\u4e00\u79cd\u60c5\u51b5\uff0c\u76f4\u63a5CAS\u5c06h2\u8282\u70b9\u6570\u636e\u8bbe\u7f6e\u4e3a\u7a7a\uff0c\u4e0d\u4f1a\u66f4\u65b0\u5934\u8282\u70b9<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"219\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVn\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5728\u7b2c\u4e09\u6b21\u51fa\u961f\u65f6\uff0c\u4e5f\u7c7b\u4f3c\u4e0e\u7b2c\u4e00\u6b21\u51fa\u961f\uff0c\u6ee1\u8db3\u7b2c\u56db\u79cd\u60c5\u51b5<\/p>\n<p>\u5728\u7b2c\u4e8c\u6b21\u5faa\u73af\u65f6\uff0c\u53bbCAS\u5c06\u6570\u636e\u8bbe\u7f6e\u4e3a\u7a7a\uff0c\u66f4\u65b0\u5934\u8282\u70b9\uff0c\u5c06\u539f\u6765\u7684\u5934\u8282\u70b9\u8bbe\u7f6e\u6210\u54e8\u5175\u8282\u70b9<\/p>\n<p><img decoding=\"async\" width=\"723\" height=\"238\" referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/bVc9QVo\" alt=\"image.png\" title=\"image.png\" loading=\"lazy\"><\/p>\n<p>\u5728\u7b2c\u56db\u6b21\u51fa\u961f\u65f6\u4f1a\u6ee1\u8db3\u7b2c\u4e09\u79cd\u60c5\u51b5\uff0c\u4f46\u6b64\u65f6p\u5c31\u662f\u9996\u8282\u70b9\uff0c\u56e0\u6b64\u4e0d\u4f1a\u66f4\u65b0\u9996\u8282\u70b9\uff0c\u7136\u540e\u8fd4\u56deNull<\/p>\n<p>\u6b64\u65f6\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\u5c3e\u8282\u70b9tail\u5728\u54e8\u5175\u8282\u70b9\u4e0a\uff0c\u5982\u679c\u5f80\u540e\u904d\u5386\u662f\u6c38\u8fdc\u65e0\u6cd5\u5230\u8fbe\u961f\u5217\u7684<\/p>\n<p>\u518d\u8fdb\u884c\u4e00\u6b21\u5165\u961f\u64cd\u4f5c\uff0c\u53d1\u73b0\u5b83\u6ee1\u8db3\u7b2c\u4e8c\u79cd\u60c5\u51b5\uff0cp\u7684next\u6307\u5411\u81ea\u5df1\uff0c\u7531\u4e8e\u672a\u88ab\u4fee\u6539\u8fc7\uff0cp\u7b49\u4e8e\u5934\u8282\u70b9\uff0c\u53c8\u91cd\u65b0\u56de\u5230\u961f\u5217\u4e0a<\/p>\n<p>\u518d\u8fdb\u5165\u4e00\u8f6e\u5faa\u73af\uff0c\u4f1aCAS\u6dfb\u52a0h4\u518d\u66f4\u65b0\u5c3e\u8282\u70b9tail<\/p>\n<p><img decoding=\"async\"   referrerpolicy=\"no-referrer\" src=\"https:\/\/segmentfault.com\/img\/remote\/1460000044255059\" alt=\"image-20230913220256751\" title=\"image-20230913220256751\" loading=\"lazy\"><\/p>\n<p>\u81f3\u6b64\uff0c\u8be5\u7b80\u5355\u793a\u4f8b\u8986\u76d6\u5927\u90e8\u5206\u5165\u961f\u3001\u51fa\u961f\u7684\u6d41\u7a0b\uff0c\u518d\u6765\u804a\u804a\u54e8\u5175\u8282\u70b9<\/p>\n<p>\u5728\u6b64\u8fc7\u7a0b\u4e2d\uff0c\u54e8\u5175\u8282\u70b9\u53ef\u4ee5\u907f\u514d\u961f\u5217\u4e2d\u53ea\u6709\u4e00\u4e2a\u8282\u70b9\u800c\u53d1\u751f\u7ade\u4e89<\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p><strong><code>ConcurrentLinkedQueue<\/code>\u57fa\u4e8e\u5355\u5411\u94fe\u8868\u5b9e\u73b0\uff0c\u4f7f\u7528volatile\u4fdd\u8bc1\u53ef\u89c1\u6027\uff0c\u4f7f\u5f97\u5728\u8bfb\u573a\u666f\u4e0b\u4e0d\u9700\u8981\u4f7f\u7528\u5176\u4ed6\u540c\u6b65\u673a\u5236\uff1b\u4f7f\u7528\u4e50\u89c2\u9501CAS+\u5931\u8d25\u91cd\u8bd5\u4fdd\u8bc1\u5199\u573a\u666f\u4e0b\u64cd\u4f5c\u7684\u539f\u5b50\u6027<\/strong><\/p>\n<p><strong><code>ConcurrentLinkedQueue<\/code>\u4f7f\u7528\u5ef6\u8fdf\u66f4\u65b0\u9996\u5c3e\u8282\u70b9\u7684\u601d\u60f3\uff0c\u5927\u5927\u51cf\u5c11CAS\u6b21\u6570\uff0c\u63d0\u5347\u5e76\u53d1\u6027\u80fd\uff1b\u4f7f\u7528\u54e8\u5175\u8282\u70b9\uff0c\u964d\u4f4e\u4ee3\u7801\u590d\u6742\u5ea6\uff0c\u907f\u514d\u4e00\u4e2a\u8282\u70b9\u65f6\u7684\u7ade\u4e89<\/strong><\/p>\n<p><strong>\u5728\u5165\u961f\u64cd\u4f5c\u65f6\uff0c\u4f1a\u5728\u5faa\u73af\u4e2d\u627e\u5230\u771f\u6b63\u7684\u5c3e\u8282\u70b9\uff0c\u4f7f\u7528CAS\u6dfb\u52a0\u65b0\u8282\u70b9\uff0c\u518d\u5224\u65ad\u662f\u5426CAS\u66f4\u65b0\u5c3e\u8282\u70b9tail<\/strong><\/p>\n<p><strong>\u5728\u5165\u961f\u64cd\u4f5c\u7684\u5faa\u73af\u671f\u95f4\u4e00\u822c\u60c5\u51b5\u4e0b\u662f\u5411\u540e\u904d\u5386\u8282\u70b9\uff0c\u7531\u4e8e\u51fa\u961f\u64cd\u4f5c\u4f1a\u6784\u5efa\u54e8\u5175\u8282\u70b9\uff0c\u5f53\u5224\u65ad\u4e3a\u54e8\u5175\u8282\u70b9\uff08next\u6307\u5411\u81ea\u5df1\uff09\u65f6\uff0c\u6839\u636e\u60c5\u51b5\u5b9a\u4f4d\u5230\u5c3e\u8282\u70b9\u6216\u5934\u8282\u70b9\uff08\u201c\u8df3\u51fa\u201d\uff09<\/strong><\/p>\n<p><strong>\u5728\u51fa\u961f\u64cd\u4f5c\u65f6\uff0c\u4e5f\u662f\u5728\u5faa\u73af\u4e2d\u627e\u5230\u771f\u6b63\u7684\u5934\u8282\u70b9\uff0c\u4f7f\u7528CAS\u5c06\u771f\u6b63\u5934\u8282\u70b9\u7684\u6570\u636e\u8bbe\u7f6e\u4e3a\u7a7a\uff0c\u518d\u5224\u65ad\u662f\u5426CAS\u66f4\u65b0\u5934\u8282\u70b9\uff0c\u7136\u540e\u8ba9\u65e7\u7684\u5934\u8282\u70b9next\u6307\u5411\u5b83\u81ea\u5df1\u6784\u5efa\u6210\u54e8\u5175\u8282\u70b9\uff0c\u65b9\u4fbfGC<\/strong><\/p>\n<p><strong>\u5728\u51fa\u961f\u64cd\u4f5c\u7684\u5faa\u73af\u671f\u95f4\u4e00\u822c\u60c5\u51b5\u4e0b\u4e5f\u662f\u5411\u540e\u904d\u5386\u8282\u70b9\uff0c\u7531\u4e8e\u51fa\u961f\u4f1a\u6784\u5efa\u54e8\u5175\u8282\u70b9\uff0c\u5f53\u68c0\u6d4b\u5230\u5f53\u524d\u662f\u54e8\u5175\u8282\u70b9\u65f6\uff0c\u4e5f\u8981\u8df3\u8fc7\u672c\u6b21\u5faa\u73af<\/strong><\/p>\n<p><strong><code>ConcurrentLinkedQueue<\/code>\u57fa\u4e8e\u54e8\u5175\u8282\u70b9\u3001\u5ef6\u8fdfCAS\u66f4\u65b0\u9996\u5c3e\u8282\u70b9\u3001volatile\u4fdd\u8bc1\u53ef\u89c1\u6027\u7b49\u7279\u70b9\uff0c\u62e5\u6709\u975e\u5e38\u9ad8\u7684\u6027\u80fd\uff0c\u76f8\u5bf9\u4e8e<code>CopyOnWriteArrayList<\/code>\u6765\u8bf4\u9002\u7528\u4e8e\u6570\u636e\u91cf\u5927\u3001\u5e76\u53d1\u9ad8\u3001\u9891\u7e41\u8bfb\u5199\u3001\u64cd\u4f5c\u961f\u5934\u3001\u961f\u5c3e\u7684\u573a\u666f<\/strong><\/p>\n<h3>\u6700\u540e\uff08\u4e0d\u8981\u767d\u5ad6\uff0c\u4e00\u952e\u4e09\u8fde\u6c42\u6c42\u62c9~\uff09<\/h3>\n<p>\u672c\u7bc7\u6587\u7ae0\u88ab\u6536\u5165\u4e13\u680f <a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=9Nf0LagFlzid2dD9wzZ0SQ%3D%3D.R%2B9g2BWLpgbCrq6zeueXqUNT%2FvHvaqJY6U5%2BQos%2BzYUheXPCaZC1IY8Ilh4p0tzn\" rel=\"noopener noreferrer\">\u7531\u70b9\u5230\u7ebf\uff0c\u7531\u7ebf\u5230\u9762\uff0c\u6df1\u5165\u6d45\u51fa\u6784\u5efaJava\u5e76\u53d1\u7f16\u7a0b\u77e5\u8bc6\u4f53\u7cfb<\/a>\uff0c\u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5\u6301\u7eed\u5173\u6ce8\u5594<\/p>\n<p>\u672c\u7bc7\u6587\u7ae0\u7b14\u8bb0\u4ee5\u53ca\u6848\u4f8b\u88ab\u6536\u5165 <a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=UlyH3pfjGiCZsZBVKUUd0g%3D%3D.eejb%2FHiQ1Fx6H%2B2YIN7vnMGjNxYnr5REjTF5IF5RTjhd0fIF2akUAzUVvg6Qcl9J\" rel=\"noopener noreferrer\">gitee-StudyJava<\/a>\u3001 <a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=B1A3EXSyQ2U%2FeTcDMUPPNw%3D%3D.fyBF819k%2B10SAfNsf2AKWM4oR%2Bs6%2BKZ10m1xPOh42Btde4le1bzJ4w806KtjpbL5\" rel=\"noopener noreferrer\">github-StudyJava<\/a> \u611f\u5174\u8da3\u7684\u540c\u5b66\u53ef\u4ee5stat\u4e0b\u6301\u7eed\u5173\u6ce8\u5594~<\/p>\n<p>\u6848\u4f8b\u5730\u5740\uff1a<\/p>\n<p><a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=AS6k%2FgJ6%2FUlfxucPWgsY8w%3D%3D.pRyWDKARW0YaAmckg8m9EL093a3%2BykQIfi13i8FS3ncAgydtJNiv9%2BDiEYyme%2FOBH16JkFK0SLoVHVEARGyyo3Ypt%2Fq2W4kLvyvyH2JWbTuM8vBnk4KlVohEbp3nDeq5bKxPAT8%2BvPxFUWc%2Bw%2BblaAexKuDw1mGLnuGLtEAeGAOYDgOAbZTvTYfgiUcmuIYM4i6f00nRDgnpoEb0JPmliURHZt06%2B3kFFNw8K1uWlgVswDxf7Kbm%2Fzf3CUahmO6d\" rel=\"noopener noreferrer\">Gitee-JavaConcurrentProgramming\/src\/main\/java\/F_Collections<\/a><\/p>\n<p><a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=qGIj6dkNNbXbF692G5cMhg%3D%3D.y652pbwgRdFQB5e%2FfdKR%2Bs0fqAtgZKiW4Xru0jEXWUvVBGE6cbXnBESwREHHIjohwc8UxAlmB9OeC7ecIyjWORkEa83DzAzIkYP3ktcDyTif7u%2FjuFCm3WM97qBzHJnvp8U%2Bh%2BH0u6bOmGLBjwPCuz44k8%2B7sMQ3WTm8F%2F5PS5X5fXOQZwmCxb09FZlf4rysU4XoHMXhH2ycByy4ZJvdBqxGnODDJ6aBq3nHWFzLpzGCLlknLtIACSCezZrt1gSC\" rel=\"noopener noreferrer\">Github-JavaConcurrentProgramming\/src\/main\/java\/F_Collections<\/a><\/p>\n<p>\u6709\u4ec0\u4e48\u95ee\u9898\u53ef\u4ee5\u5728\u8bc4\u8bba\u533a\u4ea4\u6d41\uff0c\u5982\u679c\u89c9\u5f97\u83dc\u83dc\u5199\u7684\u4e0d\u9519\uff0c\u53ef\u4ee5\u70b9\u8d5e\u3001\u5173\u6ce8\u3001\u6536\u85cf\u652f\u6301\u4e00\u4e0b~<\/p>\n<p>\u5173\u6ce8\u83dc\u83dc\uff0c\u5206\u4eab\u66f4\u591a\u5e72\u8d27\uff0c\u516c\u4f17\u53f7\uff1a\u83dc\u83dc\u7684\u540e\u7aef\u79c1\u623f\u83dc<\/p>\n<blockquote><p>\u672c\u6587\u7531\u535a\u5ba2\u4e00\u6587\u591a\u53d1\u5e73\u53f0 <a target=\"_blank\" href=\"https:\/\/link.segmentfault.com\/?enc=8VbkGAP%2B2NO0zaBC7fSYcQ%3D%3D.Gf9TVv7e%2BqfapbkbtaGJ7JUI0Bvi2bHJONsTQD4mwptjsRepCo3eaKkHnGodYQzM\" rel=\"noopener noreferrer\">OpenWrite<\/a> \u53d1\u5e03\uff01<\/p><\/blockquote>\n<p><a href=\"https:\/\/segmentfault.com\/a\/1190000044255057\">https:\/\/segmentfault.com\/a\/1190000044255057<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>12\u5f20\u56fe\u4e00\u6b21\u6027\u641e\u61c2\u9ad8\u6027\u80fd\u5e76\u53d1\u5bb9\u5668ConcurrentLinkedQueue \u524d\u8a00 \u4e0a\u7bc7\u6587\u7ae0\u804a\u5230\u5e76\u53d1\u96c6\u5408Copy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-10008326","post","type-post","status-publish","format-standard","hentry","category-share"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008326","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10008326"}],"version-history":[{"count":0,"href":"https:\/\/itmax.cn\/index.php?rest_route=\/wp\/v2\/posts\/10008326\/revisions"}],"wp:attachment":[{"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10008326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10008326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itmax.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10008326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}