As I run the following code :
import java.util.LinkedList;
class Tester {
public static void main(String args[]) {
LinkedList
The ConcurrentModificationException is thrown when iterating through the list and at the same time when you are trying to modify (add/remove) the contents of the list either through another thread or in a loop.
You can try using ConcurrentLinkedQueue or as John stated do a copy and modify the original in iteration.
Queue list = new ConcurrentLinkedQueue();
list.add("suhail");
list.add("gupta");
list.add("ghazal");
list.add("poetry");
list.add("music");
list.add("art");
int size = list.size();
for(int i = 0; i < size; i++){
list.add("art");
list.remove("art");
System.out.println(list);
}