Java ??? ? ConcurrentLinkedQueue
?????lacker ???????[ 2016/11/17 11:43:15 ] ????????Java ???
????????????p == q
?????????????????????
??????????????£????A???offer??????
????1???????????????
????2??tail = node0?? p = t = node0
????3????? Node<E> q = p.next; ???q = p.next?????node0.next
????4????? if (q == null)????????????????
???????? else if (p == q) ?????????????A???
???????A??????????
????head = node0
????tail = node0
????t = node0
????p = node0
????q = node0.next
?????????????????????????????A????????4???????????????B?????B???poll??????
??????????????
????· head = node0?? p = h = node0;
????· ??? E item = p.item;??item = null
????· if (item != null && p.casItem(item?? null)) ??????
????· ??? else if ((q = p.next) == null)??q = node1????????????
????· ??? else if (p == q)????????????
????· ??? p = q;??p = node1
??????????????
????· head = node0?? h = node0?? p = node1;
????· ??? E item = p.item;??item = node2
????· if (item != null && p.casItem(item?? null))?? item != null ???????CAS???????
????p != h ??????????updateHead
??????? updateHead(h?? ((q = p.next) != null) ? q : p); ???q = node2
??????updateHead????
????h != p ?????????CAS???????????head?????node2??
??????? h.lazySetNext(h);???????? h = node0?????????????????node0.next = node0
????· ??item????
?????????????????е????????????A??????
????head = node2
????tail = node0
????t = node0
????p = node0
????q = node0.next = node0
????????????????????? p = q = node0 ??????????????? updateHead?????? h.lazySetNext(h) ???????棬?????head.next???ó????????? head.next = head??????????????head
??????????????????????
????1?????????л?????????????????????????????
????2??????????????? Node<E> q = p.next??q??????p.next??????? p.next = node1???????p.next?????????q????????
????3????????????????????ū???????????????????????????????????????????????????????????? h.lazySetNext(h);
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11