Concurrency/Multithreading

(Simple) Thread and Runnable Identify potential threading problems among deadlock, starvation, livelock, and race conditions Use synchronized keyword and java.util.concurrent.atomic package to control the order of thread execution Use java.util.concurrent collections and classes including CyclicBarrier and CopyOnWriteArrayList Use parallel Fork/Join Framework Use parallel Streams including reduction, decomposition, merging processes, pipelines and performance. java.util.concurrent – Concurrent […]

Thread and Runnable

How to create a Thread 1. extends Thread implement run() start() 2. implements Runnable //since 1.8 Runnable is functional implement run() new Thread(new Runnable) start() 3. since 1.5 – java.util.concurrent.Callable simple as Runnable, can return value Threads features anotherVenus.join(); – waits for thread Thread.sleep(ms) – any others threads can interrupt it wait() notify() notifyAll() Timer TimerTask java.util.concurrent.Future […]