Is LinkedList thread-safe when I'm accessing it with offer and poll exclusively?

后端 未结 4 1823
长情又很酷
长情又很酷 2020-12-09 03:07

I have a linked list samples:

protected LinkedList samples = new LinkedList();

I\'m append

4条回答
  •  一生所求
    2020-12-09 03:36

    LinkedList is not thread safe. You'd have to do the locking yourself.

    Try ConcurrentLinkedQueue or LinkedBlockingDeque instead if it fits your needs, they are thread safe but slightly different behavior than LinkedList.

提交回复
热议问题