Concurrency

If you have any doubts in the below, contact us by dropping a mail to the Kung Fu Panda. We will get back to you very soon.

Basic Problem

Ways to fix synchronization issues

Thread Safety

Atomicity

Terms

Locks

Reentrancy

Synchronization

Memory Visibility and Reordering

Volatile variables

Thread confinement

Stack confinement

Immutability

Safe Publication

Adding functionality to ThreadSafe Classes

Sometimes, we may need to add functionality to existing threadsafe classes, like in SynchronizedList, add() and contains() methods are threadsafe, but their combination is not. Suppose, we need to add putIfAbsent method to SynchronizedList which adds an object to the set if it is not present. There are many ways

Other

Queue

Blocking Queue

Concurrent HashMap

CopyOnWriteArrayList

Blocking Queue and the Producer-Consumer Pattern

Types of Blocking Queue

Deque and BlockingDeque

Thread Block/Pause

Threads may block or pause for various reasons

Synchronizers

Latches

Countdown Latch

Semaphores

Barriers

Cyclic Barrier Vs Countdown Latch

If the barrier is broken, it can be reused, (because its a 'cyclic' barrier) but a count down latch cannot be reused.

FutureTask

Future

Thread Pools

Types of Thread Pool Executor

CompletionService

Cancellation and Shutdown

Reasons for cancellation

One of the below

Interruption Policies

Daemon Threads

Long running tasks

Sizing Thread Pools

Saturation Policies (when limit in thread pools is exceeded)

ThreadFactories

Deadlock

Analysing Deadlock

Starvation

LiveLock

Performance and Scalability

Amdahl's Law

System Performance

Explicit Locks

Lock


	void lock();

	void lockInterruptibly() throws InterruptedException;

	boolean tryLock();

	boolean tryLock(long timeout, TimeUnit unit) throws InterruptedException

	unlock();

ReentrantLock

ReadWriteLocks

Atomic Variables and non blocking synchronization

Optimistic Locking approach

FAQ

What are blocking methods