+ All Categories
Home > Technology > Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Date post: 13-Dec-2014
Category:
Upload: kyung-koo-yoon
View: 343 times
Download: 0 times
Share this document with a friend
Description:
Lecture on Java Concurrency Day 2 on Feb 4, 2009. (in Korean)Lectures are 4 days in all.See http://javadom.blogspot.com/2011/06/lecture-on-java-concurrency-day-2.html
18
Practical Concurrency January, 2009 http://javadom.blogspot.com/2011/06/ lecture-on-java-concurrency-day- 2.html
Transcript
Page 1: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Practical Concurrency

January, 2009

http://javadom.blogspot.com/2011/06/lecture-on-java-concurrency-day-2.html

Page 2: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Day 2 (9am, Feb 4, 2009)

Concurrency ConcernsPerformanceConcurrency Design

Page 3: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

2-1 Concurrency Concerns

CorrectnessLiveness

Page 4: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Correctness (Multi-threaded Safety)

Conflicts Read-write conflicts Write-write conflicts

Page 5: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Liveness

Blockages Lock Wait Input CPU contention Failure

Page 6: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Deadlock

A situation wherein two or more competing actions are waiting for the other to finish, and thus neither ever does. Lock-ordering deadlock Dynamic lock-ordering deadlock Resource deadlock Thread-starvation deadlock

Page 7: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Livelock

similar to a deadlock, except that the states of the processes involved in the livelock constantly change with regard to one another, none progressing

Page 8: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

2-2 Performance

Amdahl’s lawContext Switch OverheadMemory Barrier Overhead

Page 9: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Amdahl’s law

Page 10: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Context Switch Overhead

All the Registers Program Control Block

Kernel stack User Area

Text/data/stack

Page 11: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Memory Barrier a class of instructions which cause a

central processing unit (CPU) to enforce an ordering constraint on memory operations issued before and after the barrier instruction.

Assures ordered access and memory visibility in multi-processor environments

Accessing volatile fields are usually implemented using memory barrier

Page 12: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

2-3 Concurrency Design

Concurrency Design StepConcernsObjects in Worker Thread ModelCollection Design

Page 13: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Steps of Designing Concurrency

1. Identify Shared Resources2. Identify Critical Sections3. Design Lock Granularity4. Check multiple locking sanity

1. Check long critical sections2. Check possible locking order problems

Page 14: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Concerns on Designing Concurrency

Liveness Deadlock Starvation Waiting

Performance Context switching overhead Lock contention

Page 15: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Further considerations

Thread confinement Locking itself is not critical overhead

Lock contention and context switching is.

Page 16: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Worker Threads

Worker threads One thread to execute many unrelated

tasks Aka., background threads or thread pools

(when more than one thread is used) Object life cycle and work threads

Instance sharing New instance per work

Worker threads and Instance variables

Page 17: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Worker Threads and Objects JavaEE EJB Session Bean

Stateless session bean objects are pooled The container assures the serialized access

to each objects (so, always thread-safe) Statefull session bean might throw

ConcurrentAccessException JavaEE Servlet

Servlet object life cycle Objects per

Request/Session/Page/Application lifecycle

Page 18: Lecture on Java Concurrency Day 2 on Feb 4, 2009.

Worker Threads and Objects (2) JMX MBean (Local/Connector)

Creates new thread per messages Just like the servlet model

ProBus Process(or Flow) Use the same Flow class and LProcess objects

are created per flow instances (contentions against Lprocess and …)

BizMaster Workflow Process Per-process class is generated and no process

instances (contentions against RuntimeContext and …)

ProBus Adapter Rule Just like the servlet model


Recommended