클래스 패키지 : java.util.LinkedList
클래스 상속구조
java.lang.Object java.util.AbstractCollection<E> java.util.AbstractList<E> java.util.AbstractSequentialList<E> java.util.LinkedList<E>
구조
node / vertex : LinkedList를 구성하는 element 를 지칭함.
각 node는 실제 데이터를 저장하는 data field와 다음 node의 주소를 저장하는 주소 field를 가지고 있다.
head : LinkedList 의 첫 node의 주소를 가지고 있음.
size ( optional ) : LinkedList에 node가 추가/삭제 될 때마다 총 갯수를 저장하고 잇음.
tail ( optional ) : LinkedList의 마지막 node의 주소를 가지고 있음.
기본 구현 코드

import java.util.ListIterator;
/**
* @param <E>
*/
public class MyLinkedList<E> implements List<E> {
private class Node{
public E data;
public Node next;
public Node(E data) {
this.data = data;
this.next = null;
}
public Node(E data, Node next) {
this.data = data;
this.next = next;
}
}
private int size;
private Node head;
public MyLinkedList(){
head = null;
size = 0;
}
}
출처 : https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html
is not synchronized.
여러 스레드가 동시에 사용하는 중에, 구조적인 변경 ( element의 추가/삭제가 일어날 경우. 값을 바꾸는 것은 구조적 변경은 아님 )이 있다면 반드시 외부적으로 동기화 되어야 한다. 일반적으로는 리스트를 자연스럽게 캡슐화하는 객체에 동기화함으로써 가능하다. 만약 그런 객체가 없다면, 리스트는 반드시 Collections.synchronizedList 메서드를 통해 wrap해야 한다. 리스트에 실수로 동기화하지 않은 접근을 방지하기 위해 객체가 생성될 때 이루어지는 것이 최선이다.
List list = Collections.synchronizedList(new LinkedList(...));
비동기화된 상태에서 구조적 변경시 일어나는일 iterator : fail-fast
iterator가 생성될 때와 다른 구조적 변경이 일어난다면 iterator는 미래에 arbitrary, non-deterninistic behavior의 위험을 감수하느니 ConcurrentModificationException을 던지면서 신속하고 깔끔하게 죽는다.
단 fail-fast는 확정적으로 보장되지 않는다. ConcurrentMOdificationException을 최선을 다할 뿐이다? 따라서 이 예외에 기대어 프로그래밍을 하는 것은 옳지 않다. 버그를 잡기 위해서만 사용되어야한다.
java의 fail-fast / fail-safe
출처 : https://118k.tistory.com/656
Fail-Fast 방식은 동작중 오류가 발생하면 바로 오류를 알리고, 작업을 중단합니다.
Fail-Safe 방식은 동작중 오류가 발생하도 작업을 중단하지 않고 진행합니다.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
public class IteratorFailFastAndFailSafe {
public static void funcFailFast() {
ArrayList<Integer> numbers = new ArrayList<>(Arrays.asList(1, 2, 3, 4));
Iterator<Integer> iterator = numbers.iterator();
while (iterator.hasNext()) {
Integer number = iterator.next();
numbers.add(50);
System.out.println(number);
}
}
public static void funcFailSafe() {
ConcurrentHashMap<String, Integer> map = new ConcurrentHashMap<>();
map.put("First", 10);
map.put("Second", 20);
map.put("Third", 30);
map.put("Fourth", 40);
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
String key = iterator.next();
map.put(key, 50);
}
}
public static void main(String[] args) {
funcFailFast();
funcFailSafe();
}
}
double-ended linked-list
java에서 구현되어 제공되고 있는 LinkedList는 double-ended linked-list이다.

https://docs.oracle.com/javase/8/docs/api/java/util/LinkedList.html 의 Method Summary 참고.

출처 : https://footcode.tistory.com/5
ArrayList
An ArrayList class can act as a list only because it implements List only.
LinkedList
LinkedList class can act as a list and queue both because it implements List and Deque interfaces