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.
More Related Contents:
- How to put HashMap into different elements with same key
- Synchronizing on String objects in Java
- Is java.sql.Connection thread safe?
- Java synchronized method lock on object, or method?
- Is iterating ConcurrentHashMap values thread safe?
- Is a HashMap thread-safe for different keys?
- Thread safe multitons in Java
- Is a volatile int in Java thread-safe?
- Use cases for RxJava schedulers
- How to stop a thread created by implementing runnable interface?
- Throttling javafx gui updates
- Are non-synchronised static methods thread safe if they don’t modify static class variables?
- Odd even number printing using thread
- How do I prove programmatically that StringBuilder is not threadsafe?
- Is Random class thread safe?
- Thread Confinement
- Testing initialization safety of final fields
- ArrayList vs LinkedList from memory allocation perspective
- Java Synchronization [closed]
- Is Cipher thread-safe?
- How to get the Context from anywhere? [duplicate]
- Regarding thread safety of servlet [duplicate]
- Inner class can access but not update values – AsyncTask
- What is the difference between Set and List?
- How are Threads allocated to handle Servlet request?
- Removing Duplicate Values from ArrayList
- Java – creating a new thread
- Concept behind putting wait(),notify() methods in Object class [duplicate]
- Does Java have support for multicore processors/parallel processing?
- JAVAFX : why wait cursor needs a new thread?