Professional Documents
Culture Documents
Binder 3
Binder 3
JAVA CONCURRENCY
(The most important reason for most applications(Enterprise and real-time) to fail or underperform is improper design for concurrency. This is especially true because of multi cores/processor becoming ubiquitous. This training course takes a wholistic view of concurrency including designing for multi-cores/processors(including NUMA).)
Pre-requisites: Basic knowledge of Java (introductory course or equivalent practical experience). Target Audience: The target group is programmers who want to know foundations of concurrent programming and existing concurrent programming environments, in order, now or in future, to develop multithreaded applications for multi-core processors and shared memory multiprocessors. Objective: x Understand concurrency control issues in general. x Know the instruments available in Java. x Avoid common errors and pitfalls. x Understand concurrency control idioms. What you will learn: x Designing applications for multi-core/multi-processor environments through detailed concurrency patterns and design principles. x Will understand the use of highly concurrent data structures and their design, well enough to be applied in software design. x Dealing with threads and collections on a multi core .
2
x JDK 5,6,7 which have Features and Classes to harness the power of the underlying technologies. x Detecting Deadlocks and Livelocks in existing applications by following Concurrency Patterns to avoid the above mentioned. x Will understand the use of Hardware based Locking. x To quickly identify the root causes of poor performance in your applications. x Eliminate conditions that will prevent you from finding performance bottlenecks.
locking handling done by OS Hidden queue Structural modification to hidden queue by wait-notify use cases for notify-notifyAll notifyAll used as work around design issues with synchronization
Cache Coherency
c c c c
Real Meaning and effect of synchronization Volatile Final The changes in JMM
5
c c
Wait-free Stack implementation Wait-free Queue implementation Design issues with synchronization Multiple user conditions and wait queues Lock Polling techniques Reentrant Lock ReentrantReadWriteLock ReentrantLock
Lock Implementation
Based on CAS Lock Striping on table Lock Striping on LinkNodes. segregating them based on Thread safety levels
Lock Striping
ConcurrentHashMap
Structure Almost immutability Using volatile to detect interference Read does not block in common code path remove/put/resize lock
c c
For systems with more than 100 cpus/cores Constant Time key-value mapping no locks even during resize all CAS spin loop bounded faster than ConcurrentHashMap State based Reasoning
Canned Synchronizers
c
c c c c c c c
Queue Implementations
ConcurrentLinkedQueue LinkedBlockingQueue and LinkedBlockingDeque ArrayBlockingDeque ArrayDeque and ArrayBlockingDeque WorkStealing using Deques LinkedTransferQueue ConcurrentSkipList(Map/Set) Sequential Skiplist Lock based concurrent Skiplist Lock free concurrent Skiplist Concurrent Skiplist
8
Skiplists
Executor FrameWork
Configuration Hardware shapes programming idiom Exposing fine grained parallelism Divide and conquer Fork and Join Anatomy of Fork and Join Work Stealing Fork -join decomposition ParallelArray Limitations
Amdahl's Law Cache Direct mapped Address mapping in cache read write cache controller
Memory Architectures
UMA NUMA
Concurrent Reasoning
c c c c
OVERVIEW
z
JVM memory areas GC Tuning SAP standards HPJMeter JVMStat SAP Memory Analyser
z z
JAVA VS C++
# include < string> int ma in ( int a rgc, cha r ** a rgv) { int i; string * va r; for (i = 0; i < 1000; i + + ) { va r = ne w string (me mory le a king or not); de le te (va r); } }
JAVA VS C++
import ja va .la ng.String; public sta tic void ma in ( String [] a rgume nts) { int i; String va r; for (i = 0; i < 1000; i + + ) { va r = ne w String (me mory ne ve r le a king); } }